im using the following script to convert jpgs into grayscale-images. http://bubble.ro/How_to_convert_an_image_to_grayscale_using_PHP.html
i want to upgrade it to also convert pngs (with transparency) and gifs (with transparency) into grayscale images.
At the moment it's not working. I'm querying the image-src for its file-extension. If jpg, if, gif, or if png i call the appropriate imagecreatefrom-jpg-gif-png
However i'm always running the same for-loop and gifs unfortunately only get gray rectangles, every pixel is gray. Png's almost work, however transprency in pngs gets transformed to black.
Any ideas?
thank you!
imagefilter($img, IMG_FILTER_GRAYSCALE);
it's almost working. i'm still having problems with transprency. pngs with transparent background get transformed to black (the background is black). The same happens to gifs and moreover gifs with transprency don't get properly grayscaled. There are a few very graytoned colors, however there are pale greentones and redtones in it.
To obtain right pictures without black background you must follow strategy:
first create your new image item set it's alphablending to false set it's savealpha to true fil it with transparent rectangle copy your grayed picture over it
your code will be similar to this :
goodluck!
take a look at my balda pomoshnik
Use this found here http://hm2k.googlecode.com/svn/trunk/code/php/functions/imagegray.php