Page 1 of 1

Wrong depth?

Posted: 2014-09-23T08:45:26-07:00
by opilarium
Hi,

I've been practicing with Magick++ for some time. And can't understand one simple thing.
I want to get the depth (bits per pixel) of an image. In this simple case I expected a simple solution, like .depth() method of Image class.
But the thing is the method is wrong on some images.
For example if you test the images from wikipedia article about color depth http://en.wikipedia.org/wiki/Color_depth
you'll get some weird results: depth is always the same. It's 8.

Also I've found .modulusDepth() method. It's right sometimes:
1_bit.png : modulusDepth = 1
2_bit.png : modulusDepth = 2
4_bit.png : modulusDepth = 8
8_bit.png : modulusDepth = 8
true_color(24_bits).png : modulusDepth = 8

After hours of googling the answer I gave up and came here.
I suppose I'm under a delusion and don't get something about images in general.

I hope you'll help me.
Thank you for your patience after this noob question.

Re: Wrong depth?

Posted: 2014-09-23T09:27:37-07:00
by glennrp
Internally, the depth is 8 or 16 (and can be larger for Q32 and Q64 builds). Some formats such as PNG support other depths, and ImageMagick will write PNG files with depths of 1, 2, 4, 8, or 16 if this can be done without loss. For PNG files, you can use "identify -verbose" or a 3rd party application such as pngcheck to find out what depth was actually written.

Re: Wrong depth?

Posted: 2014-09-23T10:09:16-07:00
by opilarium
identify works the same. Moreover wrong depth happens to be in other formats, like jpg or tiff. Is there any way to get correct depth?