note 14729 added to function.imagecreatetruecolor.php
| From: | eric at spiderws dot com | Date: | Sun, 12 Aug 2001 14:45:20 +0000 |
| Subject: | note 14729 added to function.imagecreatetruecolor.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16599@lists.php.net to get a copy of this message | ||
This little function does it for you:
<?
$image_id = imageCreateFromJPEG($image);
for($a=0;$a<imagecolorstotal ($image_id);$a++)
{
$color = ImageColorsForIndex($image_id,$i);
$R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
($color['blue']);
$G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
($color['blue']);
$B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
($color['blue']);
ImageColorSet($image_id, $a, $R, $G, $B);
}
imageJPEG($image_id,"$image");
?>
The .299 , .578 , .114 values are estimations, and add a gamma correction to the colors. For more or
less luminace in the result, you can change these values.
Goodluck,
Eric Mulders, Netherlands
http://www.php.net/manual/en/function.imagecreatetruecolor.php