Optimizing PNG File Size

Unfortunately, at the time of this writing, PNGs are so poorly supported by both browsers and production tools that there isn’t enough practical experience available to suggest any optimizing strategies.

For Web use, PNGs will be an alternative for indexed color images, and we may find that following some of the same image-creation guidelines used for GIFs may aid in minimizing PNGs as well.

24-bit RGB images are best saved in JPEG format for use online, but if you are saving them as PNGs and are interested in keeping them as small as possible, you are basically limited to selecting the best compression filter. Greg Roelofs, one of the developers of the PNG format, describes this process as “more of a black art than a science.” As mentioned earlier, the recommended filter choices are None for indexed-color images and Adaptive for everything else. Use “level 9” (or “max”) compression regardless, and don’t use interlacing if you want maximal compression. Adding interlacing to any PNG will increase its file size.

If you are serious about optimizing PNGs, you should download Glenn Randers-Pehrson’s pngcrush application ($7 shareware, available at http://www.netgsi.com/~glennrp/pngcrush/ ). It is a command-line DOS application, but it can run in batch mode. This tool comes highly recommended by Greg Roelofs.

Get Web Design in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.