note 102966 added to function.imagefilter

From: Date: Thu, 17 Mar 2011 08:26:41 +0000
Subject: note 102966 added to function.imagefilter
Groups: php.notes 
Request: Send a blank email to php-notes+get-177958@lists.php.net to get a copy of this message
a function to make all colors gray except the only one i made it myself so the code is note so beautiful ) function imagecolorfilter($im){ $height = imagesy($im); $width = imagesx($im); for($x=0; $x<$width; $x++){ for($y=0; $y<$height; $y++){ $rgb = ImageColorAt($im, $x, $y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $c=($r+$g+$b)/3; //if($g<$r || $g<$b+20){$r=$c;$g=$c; $b=$c;}//leaves only green //if($b<$r || $b<$g){$r=$c;$g=$c; $b=$c;}//only blue if($r<$g+30 || $r<$b){$r=$c;$g=$c; $b=$c;}//only red //if($r<$g-1 || $r>$g+60 || $b>$g-50){$r=$c;$g=$c; $b=$c;}//only yellow imagesetpixel($im, $x, $y,imagecolorallocate($im, $r,$g,$b)); } } } header ("Content-type: image/jpeg"); $im = imagecreatefromjpeg("image.jpg"); imagecolorfilter($im); imagejpeg($im); ---- Server IP: 69.147.83.197 Probable Submitter: 195.18.23.66 ---- Manual Page -- http://www.php.net/manual/en/function.imagefilter.php Edit -- https://master.php.net/note/edit/102966 Del: integrated -- https://master.php.net/note/delete/102966/integrated Del: useless -- https://master.php.net/note/delete/102966/useless Del: bad code -- https://master.php.net/note/delete/102966/bad+code Del: spam -- https://master.php.net/note/delete/102966/spam Del: non-english -- https://master.php.net/note/delete/102966/non-english Del: in docs -- https://master.php.net/note/delete/102966/in+docs Del: other reasons-- https://master.php.net/note/delete/102966 Reject -- https://master.php.net/note/reject/102966 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177958) next »