Wrong depth?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
opilarium
Posts: 7
Joined: 2014-09-23T08:21:27-07:00
Authentication code: 6789

Wrong depth?

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Wrong depth?

Post 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.
opilarium
Posts: 7
Joined: 2014-09-23T08:21:27-07:00
Authentication code: 6789

Re: Wrong depth?

Post 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?
Post Reply