note 106622 added to function.imagefilter

From: Date: Wed, 23 Nov 2011 00:00:14 +0000
Subject: note 106622 added to function.imagefilter
Groups: php.notes 
Request: Send a blank email to php-notes+get-184627@lists.php.net to get a copy of this message
I had the same problem as mail at kavisiegel dot com , below, except that I needed to preserve the alpha channel. Here's what I got: <?php function imagefilterhue($im, $r, $g ,$b) { $rgb = $r + $g + $b; $col = array($r / $rgb, $b / $rgb, $g / $rgb); $height = imagesy($im); $width = imagesx($im); for ($x = 0; $x < $width; $x++) { for ($y = 0; $y < $height; $y++) { $rgb = imagecolorat($im, $x, $y); $colors = imagecolorsforindex($im, $rgb); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $newR = $r * $col[0] + $g * $col[1] + $b * $col[2]; $newG = $r * $col[2] + $g * $col[0] + $b * $col[1]; $newB = $r * $col[1] + $g * $col[2] + $b * $col[0]; imagesetpixel($im, $x, $y, imagecolorallocatealpha($im, $newR, $newG, $newB, $colors['alpha'])); } } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 72.222.214.141 ---- Manual Page -- http://www.php.net/manual/en/function.imagefilter.php Edit -- https://master.php.net/note/edit/106622 Del: integrated -- https://master.php.net/note/delete/106622/integrated Del: useless -- https://master.php.net/note/delete/106622/useless Del: bad code -- https://master.php.net/note/delete/106622/bad+code Del: spam -- https://master.php.net/note/delete/106622/spam Del: non-english -- https://master.php.net/note/delete/106622/non-english Del: in docs -- https://master.php.net/note/delete/106622/in+docs Del: other reasons-- https://master.php.net/note/delete/106622 Reject -- https://master.php.net/note/reject/106622 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184627) next »