settings
skip menu
change media type
xhtml+xml
change language
deutsch
scripting

URI: http://www.j-a-b.net/web/graf/graf-gif
last updated: 2009-12-04
© 2002-2009 Contact

up down
Subject Index

The GIF File Format

The GIF file format is one of the oldest raster graphics file types used throughout the web. It is capable of displaying images with a colour depths of 8bit, that is a maximum of 256 colours. The GIF file comes in two flavours, the older, gif87a, which is hardly used anymore and the newer gif89a, which is capable of adding transparency to an image and of storing any number of frames for animation. The popularity of this file format was partly due to these features, and above these, due to its small file sizes. The filesize is achieved by using a lossless compression algorithm called LZW algorithm. This algorithm led to lots of unpleasant inconvenience in the past, as a couple of companies, above all Unisys, enforced patents they held on variations of this algorithm.

As the colour palette of GIF images is limited to 256 colours, a mechnism known as dithering is often used to reduce hard edges and huge plain-coloured areas. However, dithering is counterproductive to the LZW-compression, which works best for images with lots of identical sequences of adjacent colours. Thus the dithering mechanism blows up filesizes, sometimes above all acceptable values.

Dithering applied to GIF images

Taking the GIF image from the first image comparison chart we now apply different methods of dithering to it.

Examples of Dithered GIF Images
original image (in PNG File Format)
TrueColor PNG
Colours:
34,426
File Size:
58,628 bytes
undithered GIF
undithered GIF
Colours:
256
File Size:
22,196 bytes
GIF - Ordered Dithering
Ordered Dithering
Colours:
256
File Size:
25,460 bytes
GIF - Advanced Floyd-Steinberg Dithering
Advanced Floyd-Steinberg Dithering
Colours:
256
File Size:
29,348 bytes
GIF - Normal Floyd-Steinberg Dithering
Normal Floyd-Steinberg Dithering
Colours:
256
File Size:
29,555 bytes
undithered GIF
undithered GIF - 16 colours
Colours:
16
File Size:
4,925 bytes
GIF - Normal Floyd-Steinberg Dithering
Normal Floyd-Steinberg Dithering - 16 colours
Colours:
16
File Size:
9,653 bytes

The reduction of the original image's colour palette of 34,426 colours to 256 and 16 colours respectively leads to quite different results depending on whether dithering is applied or not. The undithered GIF image shows poor quality in that it consists of plain-coloured areas instead of the original smooth colour gradients. But when dithering is applied, these sharp transitions are reduced, and the quality of the image is improved. However, due to the LZW compression working not very good for this sort of structure, the filesizes of the resulting dithered images are considerable higher.

Bottom Line

The GIF file format mysteriously remains one of the most popular file types for web usage despite its many disadvantages. Have a look at the data comparison and image- comparison charts for further details on the pros and cons of the GIF file format versus JPEG/ JFIF and PNG files.

Subject Index

CC logo
This page is licensed under a Creative Commons License.