Book HomeWeb Design in a NutshellSearch this book

19.3. GIF Compression

There are two main things to know about GIF compression. First, it is a "lossless" compression, meaning no image information is lost in the compression process, and the decompressed image is identical to the original. (Note that some information may be lost in the conversion process from RGB to indexed color format, but once it is converted, the compression itself is lossless.)

Second, GIF uses LZW (Lempel-Zev-Welch) compression, which takes advantage of repetition in data streams. Translated into graphic terms, this means that LZW compression is extremely efficient at condensing rows of pixels of identical color. To use a simplified example, when the compression scheme hits a row of 15 identical blue pixels, it can store the information as "15 blue," but when it encounters a row that has a gentle gradation from blue to black, it needs to store a description for every pixel along the way, therefore requiring more data. This is why GIFs are efficient at storing simple graphical images; the areas of flat color take advantage of the LZW compression.

On a historical note, Unisys, the company that holds the patent on LZW compression, caused quite a stir on the Internet in 1994 when they announced that it would begin charging licensing fees to developers incorporating GIF compression into their products. In the face of fees and legal hassles, the Internet population rushed to find nonproprietary alternatives to the GIF format, leading to the development of PNG (see Chapter 21, "PNG Format"). Unisys does enforce its patent and charges software companies fees for including GIF support, but GIF shows no sign of disappearing any time soon.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.