I believe (not sure) but --- I think this (the link you sent) is allocating the same values to R,G,B thus creating the appearance of gray-scale but not actually setting the file "type" as "Gray" I'm guessing that is what this part of the code is doing:
for ($c = 0; $c < 256; $c++) {
ImageColorAllocate($im, $c,$c,$c);
}
BUT as of PHP5 you can use the cool new built in functions (with the GD Library) -- and not have to worry about all that code. IMG_FILTER_GRAYSCALE does a great job of converting.
My problem - I believe - is in writing (maybe?) something into the header to flag it as a "Gray" type image vs. a "RGB" or "CMYK" or "Indexed" ? That's the only thing I can think of. Maybe this is a question for the PHP development team.
A true "Gray" type image is about 30% the file size of an RGB file -- as it only stores 256 shades of gray (with black as the only color - giving the apearance of gray).
RGB stores 256 shades of gray for 3 channels (with Red, Green, and Blue - giving the appearance of color). when you set the values of RGB identical (R=150, G=150, B=150) you get a "gray" color -- but it's still RGB file type.
I apologize if I'm belaboring this -- it's just a huge/frustrating issue for me -- and ALL my googling leads me to the same example -- I've spent alot of time at PHP.net and GOOGLE and I can convert a "color-looking" image to a "gray-looking" image in about 12 different ways --- BUT I have yet to actually create a file that "writes" the image as a TRUE "gray" file.
_