| re: determine if image is grayscale
Andy Hassall wrote:[color=blue]
> On Thu, 09 Sep 2004 17:24:43 GMT, "tjh" <t.hickey@ten.tsacmoc> wrote:
>[color=green]
>> i'm a bit new to PHP - i've been messing around with the GD2 image
>> functions and was wondering:
>>
>> i see a lot of information about converting a color image to
>> grayscale but i can't figure out how to determine whether an image
>> (GIF or JPG) is grayscale in the first place.
>>
>> is there a way to do this in PHP?[/color]
>
> If it's a paletted image, imagecolorsforindex(), or for a true colour
> image loop through the pixels and usage imagecolorat().
>
> All the colours should have their red, green and blue components
> equal, or near equal, if it's a greyscale image.[/color]
Looping throught all pixels may become tediously sllloooooowwww for bigger
pix. Why bother, just grayscale them regardless of previous state. Is that
an option for you ?
Pjotr |