The fastest way is to simply look at bytes 24 and 25 in the PNG file. They contain the bit depth (1, 2, 4, 8 or 16) and the type of color
- 0: gray
- 2: rgb,
- 3: indexed (colormapped),
- 4: gray + alpha or
- 6: rgba.
If the bit-bit is 8 and colortype is 3, you have PNG8, and if the bit-rate is 8 and colortype is 2, you have PNG24.
On the * nix platform, the file command will do this for you, for example,
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
source share