PNG Compression

The most notable aspect of PNG compression is that it is “lossless,” meaning no information is lost in the compression process. A decompressed PNG image will be identical to the original.

PNGs use a “deflate” compression scheme. Like GIFs, PNG’s compression works on rows of pixels, taking advantage of repetition in bytes of information. By use of filters (discussed in the next section), it can take advantage of some vertical patterns as well; however, filters are not recommended for use with palette images. PNG’s compression engine typically compresses images 5-25% better than GIF.

Filters

Before PNG compresses an image, it first runs the image data, row by row, through one of five filters. What follows are brief descriptions of each filter that may aid in making a filter selection in an image-editing tool such as Adobe Photoshop. Although these filters are available, the only two methods that should be used are None (for indexed-color images) and Adaptive (for everything else).

Full technical descriptions of each filtering algorithm appear in the PNG Specification (http://www.w3.org/TR/PNG-Filters.html ).

None

As it implies, this option applies no filter before compression. The PNG Specification recommends that the filter be set to “None” for flat, indexed color images.

Sub

This filtering algorithm analyzes relationships of image information in rows of pixels. It may be appropriate for images with horizontal color gradients (from Lynda Weinman’s Designing Web Graphics ...

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.