note 54257 added to function.imagecolorallocate

From: Date: Tue, 28 Jun 2005 14:47:30 +0000
Subject: note 54257 added to function.imagecolorallocate
Groups: php.notes 
Request: Send a blank email to php-notes+get-91096@lists.php.net to get a copy of this message
This nifty function will produce the negative of a given image! <?php /******************************** Code by Kailash Nadh http://kailashnadh.name usage: img2neg("my_pic.jpg"); *********************************/ function img2neg($pic) { header("Content-type: image/jpeg"); $source=imagecreatefromjpeg($pic); // Source $width=imagesx($source); $height=imagesy($source); $im = imagecreatetruecolor($width, $height); // Our negative img in the making for($y=0; $y < $height; $y++) { for($x=0; $x < $width; $x++) { $colors=imagecolorsforindex($source, imagecolorat($source, $x,$y)); // this is what makes the colors negative $r=255-$colors['red']; $g=255-$colors['green']; $b=255-$colors['blue']; $test=imagecolorallocate($im, $r,$g,$b); imagesetpixel($im,$x, $y, $test); } } imagejpeg($im); imagedestroy($im); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorallocate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54257 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54257&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54257&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54257&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54257&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54257&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54257&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54257&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91096) next »