Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I tell, ideally with an Imagemagick identify command, whether a particular PNG is PNG32, PNG24 or PNG8?

The %z or %[depth] gives the sample depth (not the pixel depth), which is always 8 or 16 regardless of PNG format, and %m or %[magick] just reports PNG.

share|improve this question
up vote 1 down vote accepted

In recent versions (6.6.9-2, of 2011-03-30, and later), "identify -verbose" outputs IHDR.bit_depth and IHDR.color_type:

identify -verbose g1.png | grep IHDR

png:IHDR.bit_depth : 1

png:IHDR.color_type : 0 (Grayscale)


identify -verbose png24.png | grep IHDR

png:IHDR.bit_depth : 8

png:IHDR.color_type : 2 (Truecolor)


identify -verbose png64.png | grep IHDR

png:IHDR.bit_depth : 16

png:IHDR.color_type : 6 (RGBA)

share|improve this answer
In what version was it introduced? – OrangeDog Dec 16 '15 at 15:33
@OrangeDog I added the feature to IM version 6.6.9-2, 2011-03-30 – Glenn Randers-Pehrson Dec 16 '15 at 15:56

To complete Kyle's answer, seems you have to use something like this (tested with IM 6.8.4):


type=$(identify -verbose $1 | sed -n "s/^.*png:IHDR.color_type.*(\(.*\))$/\1/p")

case "$type" in

echo $depth
share|improve this answer

Interesting question, -verbose outputs the IHDR.color_type value, more info here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.