note 79551 added to function.imagefilter

From: Date: Mon, 03 Dec 2007 00:23:32 +0000
Subject: note 79551 added to function.imagefilter
Groups: php.notes 
Request: Send a blank email to php-notes+get-132757@lists.php.net to get a copy of this message
To solve that annoying problem of having to install a pre-compiled version of GD just to get imagefilter($image,IMAGE_FILTER_NEGATE) working. here is an open source solution. uses the standard stuff included in php when you uncomment 'extension=php_gd2.dll' in the php.ini file and there ya go! Useage: <?php $im = imagecreatefromjpeg("my_fav_image.jpg"); header("Content-type: image/jpg"); imagejpeg(invertimage($im)); imagedestroy($im); ?> '================================= <?php function int2rgb($myint) { return array('red' => 0xFF & ($myint >> 0x10), 'green' => 0xFF & ($myint >> 0x8), 'blue' => 0xFF & $myint); } function invertimage($im) { $wid = imagesx($im); $hei = imagesy($im); $im2 = imagecreatetruecolor($wid,$hei); $i=0; $j=0; $rgb = array('red' => 0, 'green' => 0, 'blue' => 0); $ref = 0; for($i = 0;$i < $wid; $i++) { for($j = 0;$j < $hei; $j++) { $rgb = int2rgb(imagecolorat($im,$i,$j)); $ref = imagecolorallocate($im2,255 - intval($rgb['red']),255 - intval($rgb['green']),255 - intval($rgb['blue'])); imagesetpixel($im2,$i,$j,$ref); } } return $im2; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 216.254.28.2 ---- Manual Page -- http://www.php.net/manual/en/function.imagefilter.php Edit -- https://master.php.net/note/edit/79551 Del: integrated -- https://master.php.net/note/delete/79551/integrated Del: useless -- https://master.php.net/note/delete/79551/useless Del: bad code -- https://master.php.net/note/delete/79551/bad+code Del: spam -- https://master.php.net/note/delete/79551/spam Del: non-english -- https://master.php.net/note/delete/79551/non-english Del: in docs -- https://master.php.net/note/delete/79551/in+docs Del: other reasons-- https://master.php.net/note/delete/79551 Reject -- https://master.php.net/note/reject/79551 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132757) next »