|
|
Gif compression algorithmThe Gif file format uses the LZW compression algorithm developed by Abraham Lempel, Jakob Ziv and Terry Welch. The compression algorithm contructs a color table for an image wherein each color value is matched to a pixel. Thus, images with large areas of one color will be compressed far better than those that those that do not have such color blocks. It, therefore, follows that simple images and graphics like line art and logos are better saved as Gifs as they are likely to contain areas of single flat color and hence will be compressed more. Photographs on the other hand are much more complex images and the LZW algorithm cannot compress these very well. Let us take a look at two example. Note the file size and clarity (or quality, if you like) of the images below.
Horizontal Pixel changeOne more point on the LZW compression algorithm - it counts the pixel change horizontally. Therefore, images that involve horizontal color changes will be larger than those that have vertical color changes. Take a look at the two example images below:
And since we are on this point, what if, instead of 2 colors (as in the images above), there were several colors? Let us compare the file sizes:
You'll notice that the image that had lesser horizontal color change (the one with horizontal color bands), almost doubled in file size while the one in which we had vertical color bands increased only about 15%. Finally, the GIF compression algorithm is lossless, which means that no information is lost from the original image when its converted to a gif. Since we know that a Gif image can have only 256 colors, if your original image contained more than 256 colors, then some information will be lost. However, once converted to a gif there will not be any further loss. We'll discuss these points in detail along with examples in sessions on optimizing GIFs.
Page contents: Know more about the lossless LZW Gif compression algorithm which will help in creating small optimized gif images for the web.
Page URL: http://www.webdevelopersnotes.com/graphics/ gifs_compression_algorithm.php3
|
|