I borrowed this code from a source:
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);
}
using an image (in this case I'm using a JPEG) that is a true color image I was unable to successfully use imagecopymergegray since that washed out my hues/saturation altogether making the image illegible (imagecopymergegray + imagecreate); otherwise, the colors overrode imagecopymergegray (imagecopymergegray + imagecreatetruecolor).
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