Two types of pngs

I recently learned that there are basically two different types of png images – indexed and truecolor. Most pngs you find on the internet are probably the truecolor type. The truecolor type uses an rgb format, so each pixel is represented by either 24 bits (8 bit channel depth * 3 channels), or 48 bits (16 bit channel depth). In contrast, indexed images map each pixel onto a 256 (or less) color palette. Wikipedia has a nice graph on this.

Many image tools which produce pngs use the truecolor format. There are advantages to this, as it is a lossless compression format, and it produces nice images. It also includes an option for a separate alpha channel (meaning 32 or 64 bits per pixel), which means you can get some really nice shading. However, the quality of the image comes at a cost – size. Choosing the indexed type of png results in much smaller files, akin to a .gif. Once again, imagemagick can handle this, but by default, actually produces 16bit truecolor pngs. So you have to get the right options. Here is an example of how to convert a pdf into a png in an indexed format.

convert -density 300 -quality 90 -resize 800x600  -type PaletteMatte -depth 8 fig/jfactor.pdf fig/jfactor.png

the 2 crucial options here are -type PaletteMatte and -depth 8. For some applications, it is nice to have a truecolor png. For thumbnails on webpages, you definitely want an indexed image though, since the file size is much smaller. Indexed PNG images will also be smaller than GIF files, because PNG uses a better compression algorithm.

This entry was posted in (x)html, photography and tagged , . Bookmark the permalink.

2 Responses to Two types of pngs

  1. Yahoouj says:

    Really good work about this website was done. Keep trying more – thanks!

  2. Hi there, I consider that your case is rather insightful as it talks about lots of good information. By the way, was overcurious whether you would willing to exchange web links with my web space, as I am looking to establish contacts to further broaden and reach better audience for my web site. I do not mind you locating my contacts at the homepage, just having this web links on this particular link is good and adequate. Moreover, would you please be kind enough to contact me at my website if you are keen in swapping links, I would really like that. Best wishes from me and I hope to hear from you very soon!