Grayscale Images in PHP
Wednesday June 21, 2006

Alexa before and after we grayscale
Using the GD Library, we can convert a color image to a black and white (grayscale) image from a PHP file. We first read the file, and then convert each pixel of it to a corresponding gray value before creating our final grayscale image.


Comments
Hello,
About your Grayscale images with php article… There is a faster and easier way… the imagefilter function.
imagefilter($img, IMG_FILTER_GRAYSCALE);
Also, when dealing with PNG’s and GIF’s with transparency, the imagesavealpha function should be called with the save flag set to true so that the transparency channer is fully saved.
Here’s my little png snippet (I use it when building online menus that need grayscale buttons when they are not available; it uses 2 GET parameters: img -> it points to the filename (either absolute or relative paths) and g -> if it is defined, give the grayscale image.
Cheers!
Hi, there is a easier way. The function is calling ImageCopyMergeGray and it’s very faster!
Dennis: That function isn’t even close to being accurate