note 41842 added to function.imagecolorsforindex

From: Date: Fri, 23 Apr 2004 13:23:40 +0000
Subject: note 41842 added to function.imagecolorsforindex
Groups: php.notes 
Request: Send a blank email to php-notes+get-68665@lists.php.net to get a copy of this message
here's a function to greyscale an image even from a truecolor source (jpeg or png). slightly poor quality, but very fast... function imagegreyscale(&$img, $dither=1) { if (!($t = imagecolorstotal($img))) { $t = 256; imagetruecolortopalette($img, $dither, $t); } for ($c = 0; $c < $t; $c++) { $col = imagecolorsforindex($img, $c); $min = min($col['red'],$col['green'],$col['blue']); $max = max($col['red'],$col['green'],$col['blue']); $i = ($max+$min)/2; imagecolorset($img, $c, $i, $i, $i); } } ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorsforindex.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41842 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41842&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41842&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68665) next »