I borrowed this code from a source:
for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
{
$color = imageColorsForI ndex($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);
}
using an image (in this case I'm using a JPEG) that is a true color
image I was unable to successfully use imagecopymergeg ray since that
washed out my hues/saturation altogether making the image illegible
(imagecopymerge gray + imagecreate); otherwise, the colors overrode
imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).
Using the code I borrowed I was able to change the image.. except that
it turned jet black instead!
Has anyone ever successfully grayscaled an image using GD library? If
so, how did you do it?
Thanx
Phil
for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
{
$color = imageColorsForI ndex($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);
}
using an image (in this case I'm using a JPEG) that is a true color
image I was unable to successfully use imagecopymergeg ray since that
washed out my hues/saturation altogether making the image illegible
(imagecopymerge gray + imagecreate); otherwise, the colors overrode
imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).
Using the code I borrowed I was able to change the image.. except that
it turned jet black instead!
Has anyone ever successfully grayscaled an image using GD library? If
so, how did you do it?
Thanx
Phil
Comment