📜 ⬆️ ⬇️

Accelerate pictures: PNG instead of GIF

Note: Below is a translation of the article “Replace GIF with PNG Images” about when to use the PNG format instead of the GIF. My comments further in italics.

Introduction



Portable Network Graphics ( Portable Network Graphics, PNG ) is being developed as a more efficient, flexible and patent-free replacement for the GIF format. PNG was designed to store individual bitmap images for further distribution over computer networks (1). PNG was created in 1995 in response to pressure from Unisys and their patent for the LZW compression algorithm used in GIF. Although the term of the Unisys patent has already expired, the reasons for the transition from GIF to PNG have remained virtually unchanged (2). By replacing your GIFs with the same ones, but in PNG format, you can speed up the loading of your pages and save the traffic of your users.
')

PNG vs GIF: compression algorithms



PNG uses a deflate compression algorithm, usually with a 32KB sliding window. Deflate is an improved version of the Lempel-Ziv (LZ77) compression algorithm, which is used in ZIP and GZIP files (3, 4). Created by Phil Katz for the second version of PKZip, deflate combines LZ77 with Huffman coding and is from 10% to 30% more effective than LZW in compression without loss of information. As well as GZIP, some PNG compression tools suggest the optional “compression ratio” parameter, which ranges from 1 to 9. The default setting is 6. 9 is almost always the best choice for maximum compression.

Not surprisingly, images saved as PNGs are usually from 10% to 30% smaller than GIF, although in some rare cases they may be larger in size (5, 6). In our testing, we found that some images may be compressed from 40% to 50% or even more (up to 85% for one example), depending on the image. For the most part, images with large monochromatic areas shrink better than gradient ones with more transitions between colors.

read further on webo.in →

Source: https://habr.com/ru/post/31486/


All Articles