src/UI/Image/TransparentWatermark.php
public function markImage ( $imageResource) {
		if (!$this->stampImage) {
			$this->errorMsg="Stamp image is not set.";
			return(false);
		}
		$imageWidth  = imagesx( $imageResource);
		$imageHeight = imagesy( $imageResource);

		//set position of logo
		switch ($this->stampPositionX) {
			case transparentWatermarkOnLeft: 
			$leftStamp=0;
			break;
			case transparentWatermarkOnCenter:
			$leftStamp=($imageWidth - $this->stampWidth)/2;
			break;
			case transparentWatermarkOnRight:
			$leftStamp=$imageWidth - $this->stampWidth;
			break;
			default :
			$leftStamp=0;
		}
		switch ($this->stampPositionY) {
			case transparentWatermarkOnTop:
			$topStamp=0;
			break;
			case transparentWatermarkOnMiddle:
			$topStamp=($imageHeight - $this->stampHeight)/2;
			break;
			case transparentWatermarkOnBottom:
			$topStamp=$imageHeight - $this->stampHeight;
			break;
			default:
			$topStamp=0;
		}
		
		// for each pixel of stamp
		for ($x=0; $x<$this->stampWidth; $x++) {
			if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue;
			for ($y=0; $y<$this->stampHeight; $y++) {
				if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue;
				
				// search RGB values of stamp image pixel
				$indexStamp=ImageColorAt($this->stampImage, $x, $y);
				$rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp);

				
				// search RGB values of image pixel
				$indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp);
				$rgbImage=imagecolorsforindex ( $imageResource, $indexImage);

				$randomizer=0;
				
				// compute new values of colors pixel
				$r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00);
				$g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00);
				$b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00);
				
				// change  image pixel
				imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b);
			}
		}
	}
public function markImage ( $imageResource) {
		if (!$this->stampImage) {
			$this->errorMsg="Stamp image is not set.";
			return(false);
		}
		$imageWidth  = imagesx( $imageResource);
		$imageHeight = imagesy( $imageResource);

		//set position of logo
		switch ($this->stampPositionX) {
			case transparentWatermarkOnLeft: 
			$leftStamp=0;
			break;
			case transparentWatermarkOnCenter:
			$leftStamp=($imageWidth - $this->stampWidth)/2;
			break;
			case transparentWatermarkOnRight:
			$leftStamp=$imageWidth - $this->stampWidth;
			break;
			default :
			$leftStamp=0;
		}
		switch ($this->stampPositionY) {
			case transparentWatermarkOnTop:
			$topStamp=0;
			break;
			case transparentWatermarkOnMiddle:
			$topStamp=($imageHeight - $this->stampHeight)/2;
			break;
			case transparentWatermarkOnBottom:
			$topStamp=$imageHeight - $this->stampHeight;
			break;
			default:
			$topStamp=0;
		}
		
		// for each pixel of stamp
		for ($x=0; $x<$this->stampWidth; $x++) {
			if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue;
			for ($y=0; $y<$this->stampHeight; $y++) {
				if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue;
				
				// search RGB values of stamp image pixel
				$indexStamp=ImageColorAt($this->stampImage, $x, $y);
				$rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp);

				
				// search RGB values of image pixel
				$indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp);
				$rgbImage=imagecolorsforindex ( $imageResource, $indexImage);

				$randomizer=0;
				
				// compute new values of colors pixel
				$r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00);
				$g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00);
				$b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00);
				
				// change  image pixel
				imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b);
			}
		}
	}
public function markImage ( $ imageResource ) { if ( ! $ this -> stampImage ) { $ this -> errorMsg = "Stamp image is not set." ; return ( false ) ; } $ imageWidth = imagesx ( $ imageResource ) ; $ imageHeight = imagesy ( $ imageResource ) ; //set position of logo
 switch ( $ this -> stampPositionX ) { case transparentWatermarkOnLeft : $ leftStamp = 0 ; break ; case transparentWatermarkOnCenter : $ leftStamp = ( $ imageWidth - $ this -> stampWidth ) / 2 ; break ; case transparentWatermarkOnRight : $ leftStamp = $ imageWidth - $ this -> stampWidth ; break ; default : $ leftStamp = 0 ; } switch ( $ this -> stampPositionY ) { case transparentWatermarkOnTop : $ topStamp = 0 ; break ; case transparentWatermarkOnMiddle : $ topStamp = ( $ imageHeight - $ this -> stampHeight ) / 2 ; break ; case transparentWatermarkOnBottom : $ topStamp = $ imageHeight - $ this -> stampHeight ; break ; default : $ topStamp = 0 ; } // for each pixel of stamp
 for ( $ x = 0 ; $ x < $ this -> stampWidth ; $ x ++ ) { if ( ( $ x + $ leftStamp < 0 ) || ( $ x + $ leftStamp >= $ imageWidth ) ) continue ; for ( $ y = 0 ; $ y < $ this -> stampHeight ; $ y ++ ) { if ( ( $ y + $ topStamp < 0 ) || ( $ y + $ topStamp >= $ imageHeight ) ) continue ; // search RGB values of stamp image pixel
 $ indexStamp = ImageColorAt ( $ this -> stampImage , $ x , $ y ) ; $ rgbStamp = imagecolorsforindex ( $ this -> stampImage , $ indexStamp ) ; // search RGB values of image pixel
 $ indexImage = ImageColorAt ( $ imageResource , $ x + $ leftStamp , $ y + $ topStamp ) ; $ rgbImage = imagecolorsforindex ( $ imageResource , $ indexImage ) ; $ randomizer = 0 ; // compute new values of colors pixel
 $ r = max ( min ( $ rgbImage [ "red" ] + $ rgbStamp [ "red" ] - 0x80 , 0xFF ) , 0x00 ) ; $ g = max ( min ( $ rgbImage [ "green" ] + $ rgbStamp [ "green" ] - 0x80 , 0xFF ) , 0x00 ) ; $ b = max ( min ( $ rgbImage [ "blue" ] + $ rgbStamp [ "blue" ] - 0x80 , 0xFF ) , 0x00 ) ; // change  image pixel
 imagesetpixel ( $ imageResource , $ x + $ leftStamp , $ y + $ topStamp , ( $ r << 16 ) + ( $ g << 8 ) + $ b ) ; } } }
mark an image

@param int $imageResource resource of image
@return boolean
@access public
@uses stampWidth
@uses stampHeight
@uses stampImage
@uses stampPositionX
@uses stampPositionY
mark an image