Is there a way to find out if a PNG is the 8 or 24 type? Ive tried with windows, fireworks and photoshop but I can't figure this out. Thanks
-
3Use [libpng](http://www.libpng.org/pub/png/libpng.html). It has a somewhat opaque [documentation](http://www.libpng.org/pub/png/libpng-manual.txt), but once you get through to `png_read_png()` and `png_get_bit_depth()` and `png_get_channels()`, you have what you need. If you want a command line tool, check out [ImageMagick](http://www.imagemagick.org/) (in particular the `identify` command). – Kerrek SB Jun 08 '11 at 11:45
5 Answers
The quickest way is to just peek at bytes 24 and 25 in the PNG file. They contain the bit depth (1, 2, 4, 8, or 16) and color type
- 0: gray,
- 2: rgb,
- 3: indexed (colormapped),
- 4: gray+alpha, or
- 6: rgba.
If the bitdepth is 8 and the colortype is 3 you have a PNG8, and if the bitdepth is 8 and colortype is 2 you have a PNG24.
On a *nix platform, the "file" command will do this for you, e.g.,
A PNG8:
glenn.rp> file logo.png
logo.png: PNG image data, 640 x 480, 8-bit colormap, non-interlaced
A PNG24:
glenn.rp> file rose.png
rose.png: PNG image data, 70 x 46, 8-bit/color RGB, non-interlaced

- 11,940
- 3
- 37
- 61
-
3This should be the accepted answer. I guarantee nearly everyone who got here did so because they wonder how to do it in CODE. – tayoung Nov 25 '17 at 03:31
-
1
Open it in Photoshop and check what's written on the top bar. If it says "index", then it has been saved as 8-bit PNG, if it says "RGB/8" then your PNG is a 32-bit one. Alternatively you can open Image/Mode menu and for an 8-bit one it would be "Indexed color", while for a 32-bit one - "RGB color".
Another really quick way to tell without opening the file is to see if there is any smooth gradient transparencies in the image. 8 bit pngs don't have transparent gradients - it's either fully opaque or fully transparent (nothing in between).
(For those who don't have Photoshop)
Howto identify bit depth for image files on Windows:
*Right click* image file > Properties > Details > Bit depth

- 50,002
- 13
- 138
- 166
-
just have to say that I love your icon, Dr. Snuggles is a childhood favorite :-) – Fredrik Pihl Jun 08 '11 at 11:50
-
i recently found out that they produced some new episodes a few years ago with "new graphics", but as far as i was able to tell the look and feel is similar to the old episodes – Thariama Jun 08 '11 at 12:12
-
then I learnt something new on SO today ;-) off to google now to locate those episodes! – Fredrik Pihl Jun 08 '11 at 12:17
-
(offtopic): now i remember what that was, it was only the trailer i have seen (http://www.youtube.com/watch?v=Ti8nJYmC7W0). no new episodes (none that i found) :( – Thariama Jun 08 '11 at 12:56
-
In a Linux based environment, one could use the file
command.
$ file image-1.png
PNG image data, 3840 x 2160, 8-bit/color RGBA, non-interlaced
So based on the output above, image-1.png has four channels (RGBA - red, green, blue, alpha). 8-bit per channel which sums up to 32 bits.
$ file image-2.png
PNG image data, 3840 x 2160, 8-bit/color RGB, non-interlaced
image-2.png has only 3 channels (RGB). It does not have the alpha channel. So it is in PNG‑24 format.
There's also identify
command from ImageMagick that could use to retrieve more detailed information about image files.
sudo apt-get install imagemagick
identify -verbose image.png

- 11,904
- 2
- 71
- 68
Just add the 'Bit Depth' column and it should show you the Bit depth right in the details view in file explorer.

- 108
- 6
This way for Mac Os
Right Click > Get Info
My image appears to be 32 bit in total.
Color space: RGB (3 * 8 bit = 24 bit)
Alpha channel: Yes (8 bit)
Result:
24 + 8 = 32 bit

- 91
- 1
- 4