How can I find out if a PNG file is 24 bit color or 32 bit color on Mac OS X?

16

5

I have PNG image files on Mac OS X. How can I find out if an image is 24 bit color or 32 bit color?

michael

Posted 2010-06-04T00:41:55.560

Reputation: 4 127

1Questions were merged, that's why there are duplicate answers. – Daniel Beck – 2012-02-03T11:59:03.097

Answers

20

Mac OS X also comes with a utility built into it called sips that could be used to query and manipulate different attributes of image files. As an example, you could use the following command to display all image properties associated with the image:

sips -g all image.png

Ryan

Posted 2010-06-04T00:41:55.560

Reputation: 1 488

2The relevant sips properties are samplesPerPixel and bitsPerSample. – Daniel Beck – 2012-02-02T19:03:50.497

3By the way, if you can use another answer by 1:1 copying it, the question's most probably a duplicate. In this case, please don't answer it, but flag it for moderator attention to have it closed as a dupe instead. – slhck – 2012-02-02T21:42:08.513

Ah, so do you just choose 'it needs moderator attention', choose other, and then write in duplicate? – Ryan – 2012-02-02T23:19:21.803

1@Ryan: "It doesn't belong here" -> "Exact Duplicate" -> Paste link. – Tamara Wijsman – 2012-02-03T11:56:05.857

12

pngcheck will give a succinct description (and any errors, should they exist):

$ pngcheck *.png
OK: sample24.png (128x128, 24-bit RGB, non-interlaced, 89.7%).
OK: sample32.png (128x128, 32-bit RGB+alpha, non-interlaced, 78.0%).

No errors were detected in 2 of the 2 files tested.

Mac binaries available on supplied link.

Mike Fitzpatrick

Posted 2010-06-04T00:41:55.560

Reputation: 15 062

Good answer - the sips suggestion didn't work for me - Both png-8 and png-24 files are reported as 8 bit sRGB. Another working answer is also file *.png - no extra installs required. png-8 will show as "colormap" whereas png-24 shows as "color RGB". – Jonny – 2014-06-25T07:13:10.880

3

If you are on a Mac and have homebrew, you can install it with: brew install pngcheck

– gdelfino – 2012-03-28T11:46:41.700

7

ImageMagick's identify utility (command line) will show you all sorts of info about images in a range of formats.

identify -verbose <image file>

If your image is 24 bit you will see:

Channel depth:
  red: 8-bit
  green: 8-bit
  blue: 8-bit

If your PNG image is 32 bit you will see:

Channel depth:
  red: 8-bit
  green: 8-bit
  blue: 8-bit
  alpha: 8-bit

There will be a lot of other information displayed as well.

Mike Fitzpatrick

Posted 2010-06-04T00:41:55.560

Reputation: 15 062

4

You can query Spotlight's metadata index using mdls:

mdls -name kMDItemBitsPerSample filename.png
kMDItemBitsPerSample = 32

The results seem a bit odd though. mdls -name kMDItemHasAlphaChannel might be more relevant here.

Daniel Beck

Posted 2010-06-04T00:41:55.560

Reputation: 98 421

3

In addition to what has been suggested, Mac OS X comes with a utility built into it called sips that could be used to query and manipulate different attributes of image files. As an example, you could use the following command to display all image properties associated with the image:

sips -g all image.png

ayaz

Posted 2010-06-04T00:41:55.560

Reputation: 8 106