Page 1 of 1

Re: RGB to Greyscale?

Posted: 2007-11-30T17:13:17-07:00
by Maxwell
Hello Philippe,

I downloaded the PNG linked from
The best I'm able to achieve is 32-bit RGB PNG that looks like a grayscale image.
and It was identified as 8-bit.

Code: Select all

> identify greyscale.png 
greyscale.png PNG 128x128 128x128+0+0 DirectClass 8-bit 16.8613kb
What makes you say it is still 32bit?

(pause)

I went to your test page and my browser (Opera) thinks the Actual is 24-bit and the expected is 8-bit. So I downloaded the Actual and identify says it is 8-bit--same results as above. So then I downloaded the Expected and checked it

Code: Select all

> identify greyscale_expected.png
greyscale_expected.png PNG 128x128 128x128+0+0 PseudoClass 256c 8-bit 10.9004kb 
The differene is DirectClass and PseudoClass 256c 8-bit and now I'm lost...

Hope some of this helps,
Max

Re: RGB to Greyscale?

Posted: 2007-12-03T18:49:56-07:00
by anthony
DirectClass means colors are defined directly in the array. You can thus have a different color for each individual pixel. for Grayscale each color is 8bit, and is quite economical.

PsuedoColor, means instead of an array of colors, it uses an array of color indexes into a table of colors. for 8 bit that means the image is limited to 256 colors! with eaith index also being 8bit, though the colors themselfs can be a 8 bit grayscale or a 24 bit RGB color. This is how GIF format works.

A 8 bit greyscale image may as well be DirectColor, for all the optimization savings a PsuedoColor indexed table of colors provides!

In IM you can set -type PsuedoColor (if this works depend of the output coder) or use PNG8:image.png, to use the special "PNG in a GIF-like format" coder.

Alternatively you can use external PNG specific programs to optimize the format without loss of quality ("optipng"), or quantize the colors into a 8bit color table ("pngng").