header("Content-type: image/jpeg"); $input=imagecreatefromjpeg($_REQUEST['name']); // input image file path $width=imagesx($input); // Width of image $height=imagesy($input); // Height of image $im = imagecreatetruecolor($width, $height); // output image for($y=0; $y < $height; $y++) { for($x=0; $x < $width; $x++) { $colors=imagecolorsforindex($input, imagecolorat($input, $x,$y)); // Extract the pixel color // Image Processing code here [START] // Code for generating Black and white copy of image. $common = ($colors['red']+$colors['blue']+$colors['green'])/3; $r=$common; $g=$common; $b=$common; // Code for generating Negative copy of image. $r=255-$colors['red']; $g=255-$colors['green']; $b=255-$colors['blue']; // Image Processing code here [END] $color=imagecolorallocate($im, $r,$g,$b); imagesetpixel($im,$x, $y, $color); } } $textcolor = imagecolorallocate($im, 0, 0, 255); // Write the string (watermark) at the bottom left imagestring($im, 3, 5, $height-15, 'WWW.PUNEETK.COM', $textcolor); imagejpeg($im); imagedestroy($im);