Page 1 of 1

converting a jpeg image from color to grayscale with gd2

Posted: Sun Jun 01, 2003 10:43 am
by zappamad
How to convert a color jpeg image (opened in truecolor mode with the imagecreatefromjpeg() function since gd2) into grayscale image without use imagetrucolortopalette() function which destroy the photo ?

every code using palette of the image opened with imagecreatefromjpeg() works fine with gd 1.6, but no more with gd2 cause the image is open in true color mode with no palette :?

thanks everyone.

Posted: Mon Jun 02, 2003 5:47 am
by pootergeist
http://teckis.com/compiled_files/img_create.php

the greyscale function within that class will do it fine - feel free to pull the code apart and just use that function alone if you want.

you could also use imagecopymergegray() , though the weight levels for the RGB indexes are not user definable there.