Computer Graphics


158pages on
this wiki
Add New Page
Talk0 Share
File:Sunflower as GIF picture.gif
File:Rotating earth (small).gif

Template:Infobox file format Template:Otheruses GIF (Graphics Interchange Format) is a bitmap image format for pictures with up to 256 distinct colours from the over 16 million representable in 24 bit rgb. The format was introduced by CompuServe in 1987 and has since come into widespread usage on the World Wide Web. GIFs are compressed files, and were adopted to reduce the amount of time it takes to transfer images over a network connection.

A GIF file employs lossless data compression so that the file size of an image may be reduced without degrading the visual quality, provided the image fits into 256 colours. (However, there is a hack that can overcome this limitation under certain circumstances; see #truecolour.) The GIF format's 256-colour limitation makes it unsuitable for photographs, though losslessly compressed photographs tend to be unacceptably large for the web anyway. On the other hand the lossy JPEG format does poorly on sharp transitions like those in diagrams or text, producing highly visible artifacts and little file-size reduction. Therefore GIF is normally used for diagrams, buttons, etc., that have a small number of colours, while the JPEG format is used for photographs.

Many software developers were caught by surprise when it was revealed that the GIF format had been patented by Unisys, and that they would have to pay royalties for writing programs that generated (or displayed) GIF files. The desire for a comparable format with fewer legal restrictions (as well as fewer technical restrictions such as the number of colours) led to the development of the PNG (Portable Network Graphics) standard. Although the GIF patents will expire in the near future, PNG is still touted as a technically superior alternative, and has become the third most common image format on the web. The latest expiration date of the GIF-related patents will most probably be Friday, 11 August 2006 [1].


The GIF format was introduced in 1987 by CompuServe in order to provide a colour image format for their file downloading areas, replacing their earlier RLE format which was black and white only. GIF became popular because it used LZW data compression, which was more efficient than the run-length encoding that formats such as PCX and MacPaint used, and fairly large images could therefore be downloaded in a reasonable amount of time, even with very slow modems.

The original version of GIF was called 87a. In 1989, CompuServe devised an enhanced version, called 89a [2], that added support for multiple images in a stream, interlacing and storage of application-specific metadata. The two versions can be distinguished by looking at the first six bytes of the file, which, when interpreted as ASCII, read "GIF87a" and "GIF89a", respectively.

When the World Wide Web gained popularity, GIF became one of the two image formats commonly used on Web sites, the other being the black and white XBM. JPEG came later with the Mosaic browser.

The GIF89a feature of storing multiple images in one file, accompanied by control data, is used extensively on the web to produce simple animations. The optional interlacing feature, which stored image scanlines out of order in such a fashion that even a partially downloaded image was somewhat recognizable, also helped GIF's popularity, as a user could abort the download if it was not what was required.

GIF images are limited to 256 colours, though it is possible to hack around this limitation, under certain circumstances, using the animation feature (see colour).


Some English-speakers pronounce the acronym "GIF" with a plosive (as in the word "gift"). Others pronounce it with an affricate (as in the word "giraffe"). There is evidence, including comments from Bob Berry, one of the format's creators, suggesting the affricate pronunciation is correct. Further evidence of the affricate pronunciation comes from Steve Wilhite, another one of the format's creators, who suggested that "Choosy programmers choose GIF", which suggests using the pronunciation of "Jif", a brand of peanut butter that used the marketing slogan "Choosy mothers choose Jif."

The creators of the file format pronounced the acronym as "JIF" during its unveiling presentation in the 1980s.

Unisys and LZW patent enforcementEdit

The LZW compression algorithm was covered by Template:US patent, owned by Unisys Corporation. When CompuServe first developed the GIF format, they did not know that LZW was covered by a patent. In December 1994, after Unisys discovered that the newly-popular file format used LZW compression, they announced that they would be seeking royalties on that patent; all commercial programs capable of producing GIF files would be required to pay a license fee to Unisys.

By this time, GIF was in such widespread use that most companies producing these programs had little choice but to pay. These problems were one factor leading to the development of the PNG format, which has become the third common image format on the Web after GIF and JPEG.

In late August 1999, Unisys terminated its royalty-free LZW technology licenses for free software and non-commercial proprietary software and even for individual users of unlicensed programs, prompting the League for Programming Freedom to launch the Burn All GIFs campaign to inform the public of the alternatives.

Many legal experts have concluded that the patent does not cover devices that can only uncompress LZW data and cannot compress it; for this reason, the popular gzip program can read .Z files but cannot write them.

On June 20, 2003, the United States patent on the LZW algorithm expired [3], which means that Unisys and Compuserve can no longer collect royalties for use of the GIF format in that country. Those bothered with the patent enforcement dubbed this day GIF Liberation Day. The equivalent patents in Europe and Japan expired on June 18 and June 20 2004 respectively, with the Canadian patent following on July 7.

IBM has also patented the LZW algorithm, but has never enforced this patent. According to the Free Software Foundation that patent will expire on August 11 2006 in the United States.


Even with the general adoption of broadband, the size of downloads continues to be a critical issue on the world wide web. Large web pages have a negative effect on user experience by being slow to render. Large web pages are also more expensive for their owners, who pay based on the amount of data transferred by their site. Therefore GIF's compression makes it desirable as an image format for use on webpages.

Apart from the SWF format of Macromedia Flash, GIF is the only widely used image format to support animation. It is frequently used to make small animations and short, low-resolution films for web pages.

Most web page logos and design element images are GIF or PNG because those are designed to successfully compress images that contain large blocks of the same colour or of repeating patterns; JPEG does not compress flat, single-hued areas with sharp transitions to adjacent areas well.

JPEG is preferred for digital photographs because it allows images to contain more than 16 million different hues (GIF gives a choice of only 256 per image) and it compresses photographs better. Uncompressed bitmap formats like Windows bitmap are sometimes preferred for images in computer software when speed is more important than reduced file size, because uncompressed bitmaps can be displayed more quickly.


GIF is palette based: although any palette selection can be one of millions of shades, the maximum number that can be used in a frame is 256. These are stored in a "palette", a table which associates each palette selection number with a specific RGB value. The limitation to 256 shades seemed reasonable at the time of GIF's creation because few people could afford the hardware to display more. Simple graphics, line drawings, cartoons, and grey-scale photographs typically need fewer than 256 shades. Optionally, one of the selections in the palette can be set as transparent, which allows simple binary transparency.

There exist ways to dither or diffuse photographs by using pixels of 2 or more different hues to approximate an in-between hue, but this transformation inevitably loses some detail. The algorithms used to select the palette and to perform the dithering vary widely in output quality, giving dithering a possibly unwarranted bad reputation. Additionally, dithering significantly reduces the image's compressibility and thus works contrary to GIF's main purpose.

In the early days of graphical web browsers graphics cards with 8-bit buffers (allowing only 256 hues) were common and it was fairly common to make GIF images using the websafe palette which was based on the common subset of the standard Windows and Macintosh palettes. This ensured predictable display but severely limited the choice of hues. Now that 24-bit graphics cards are the norm, optimised palettes make more sense when creating images, though there are still many sites on web design that advise the use of the websafe palette.

GIF89a was designed based on the principle of rendering images (known as frames when used for animation) to a logical screen. Each image could optionally have its own palette, and the format provides flags to specify delay and waiting for user input (not widely supported by viewers) between them. This is the feature that is used to create animated GIFs, but it can also be used to losslessly store a 24-bit RGB (truecolour) image by splitting it up into pieces small enough to be encoded into a 256 colour palette and setting up the GIF to render these with no delay on the logical screen (demo). Unfortunately, most web browsers seem to assume that this multi-image feature will only be used for animation and insert a minimum delay between images. There will be some file size bloat from doing this, especially if the encoder doesn't support LZW for patent reasons. There are very few tools around that can easily produce these GIFs, and it is rarely an appropriate format unless there is absolutely no other option.


The PNG format was specifically designed to replace GIF for use as a single-image web format. PNG offers better compression and more features than GIF. The format is rapidly replacing GIF for still images, mostly on web sites of computer enthusiasts protesting Unisys's license policies and on some webcomic sites that take advantage of PNG's tighter compression to save on internet bandwidth charges.

All the features of GIF except animation are supported by PNG. As new web browsers support PNG, most GIF images could be replaced by PNG images. Unfortunately, Internet Explorer does not support PNG's alpha channel transparency feature, and displays PNG images using that feature quite differently from the way they are intended to look.

There have been occasional mistaken claims that PNG files are larger than GIFs. These claims can generally be traced back to poor PNG support in older versions of some image manipulation programs, such as Adobe Photoshop. For example, an 8-bit GIF might be converted to a 24-bit PNG if the program being used only supported a subset of PNG's encoding schemas.

MNG, the animation-supporting relative of PNG, reached version 1.0 in 2001, but few applications support it. It has therefore had little impact on the use of GIFs for animation. Today animations may be the only field where GIF is needed, because of the lack of web browser support for MNG.

In 2004, a proposed extension to the PNG format, called APNG was suggested. It would add the ability to animate PNG files, while retaining backwards compatibility in decoders which cannot understand the animation chunk. Such decoders would simply display it as though it were a single image PNG file.

See alsoEdit

External linksEdit

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.