The Graphics Interchange Format (GIF) is a bitmap image format that was introduced by CompuServe in 1987 and has since come into widespread usage on the World Wide Web due to its wide support and portability.
The format supports up to 8 bits per pixel, allowing a single image to reference a palette of up to 256 distinct colors chosen from the 24-bit RGB color space. It also supports animations and allows a separate palette of 256 colors for each frame. The color limitation makes the GIF format unsuitable for reproducing color photographs and other images with continuous color, but it is well-suited for simpler images such as graphics or logos with solid areas of color.
GIF images are compressed using the Lempel-Ziv-Welch (LZW) lossless data compression technique to reduce the file size without degrading the visual quality. This compression technique was patented in 1985. Controversy over the licensing agreement between the patent holder, Unisys, and CompuServe in 1994 inspired the development of the Portable Network Graphics (PNG) standard; since then all the relevant patents have expired.
The original version of the GIF format was called 87a. In 1989, CompuServe devised an enhanced version, called 89a, 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.
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 stores image scan lines 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.
There exist ways to dither or diffuse photographs by using pixels of 2 or more different colors to approximate an in-between color, but this transformation inevitably loses some detail. The algorithms used to select the palette and to perform the dithering vary widely in output quality. 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 colors) 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 colors. Now that 24-bit graphics cards are the norm, optimized palettes make less sense when creating images, though some web designers still advise the use of the web safe palette.
GIF89a was designed based on the principle of rendering images (known as frames when used for animation) to a logical, fixed-size screen. Each image could optionally have no delay after it is rendered, and could have its own 256-color palette. Also, each image need not fill the entire logical screen, and the animation can cease after the last frame; it need not begin again. The multi-frame, zero-delay, and unique-palette features, optionally combined with transparency, allow for each image to replace only a portion of the previous image's pixel data. When used without looping, a more-than-256-color final result can be achieved.
For example, a GIF can be encoded to render as a series of overlapping full-screen images, each image filling in color that wasn't in the previous one. Transparent pixels can be used to preserve colors from previous images.
A similar method that doesn't use transparency is to encode the GIF to render as a series of less-than-full-screen images adjacent to each other, rather than overlapping.
These methods are not widely supported by GIF-generating software, and Web browsers and other image viewers may not contain completely compliant GIF89a implementations, so their ability to display such GIFs accurately may be limited.
Welch filed a patent application for the LZW method in June 1983. The resulting patent,, granted in December 1985, was assigned to Sperry Corporation who subsequently merged with Burroughs Corporation in 1986 and formed Unisys. Further patents were obtained in the United Kingdom, France, Germany, Italy, Japan and Canada.
In June 1984, an article by Welch was published in the IEEE magazine which publicly described the LZW technique for the first time. LZW became a popular data compression technique and, when the patent was granted, Unisys entered into licensing agreements with over a hundred companies.
The popularity of LZW led CompuServe to choose it as the compression technique for their GIF format, developed in 1987. At the time, CompuServe were not aware of the patent. Unisys became aware that the GIF format used the LZW compression technique and entered into licensing negotiations with CompuServe in January 1993. The subsequent agreement was announced on December 24, 1994. Unisys stated that they expected all major commercial on-line information services companies employing the LZW patent to license the technology from Unisys at a reasonable rate, but that they would not require licensing, or fees to be paid, for non-commercial, non-profit GIF-based applications, including those for use on the on-line services.
Following this announcement, there was widespread condemnation of CompuServe and Unisys, and many software developers threatened to stop using the GIF format. The PNG format was developed in 1995 as an intended replacement. However, obtaining support from the makers of Web browsers and other software for the PNG format proved difficult and it was not possible to replace the GIF format entirely, although PNG has gradually increased in popularity.
In August 1999, Unisys changed the details of their licensing practice, announcing the option for owners of Billboard and Intra net Web sites to obtain licenses on payment of a one-time license fee of $5000 or $7500. Such licenses were not required for website owners or other GIF users who had used licensed software to generate GIFs. Nevertheless, Unisys was the subject of thousands of online attacks and abusive emails from users believing that they were going to be charged $5000 or sued for using GIFs on their websites.. Despite giving free licenses to hundreds of non-profit organizations, schools and governments, Unisys was completely unable to generate any good publicity and continued to be vilified by individuals and organizations such as the League for Programming Freedom who started the "Burn All GIFs" campaign
The US LZW patent expired on June 20, 2003. The counterpart patents in the United Kingdom, France, Germany and Italy expired on June 18, 2004, the Japanese counterpart patents expired on June 20, 2004 and the counterpart Canadian patent expired on July 7, 2004. Consequently, while Unisys has further patents and patent applications relating to improvements to the LZW technique, the GIF format may now be used freely.
Although it took time for the PNG format to be supported, new web browsers support the PNG format and GIF images can usually be replaced by PNG images if desired. However, Internet Explorer versions 6 and earlier do not support PNG's alpha channel transparency feature without using Microsoft-specific HTML extensions. Using standard HTML <img> tags for PNG images in Internet Explorer can produce a look different from that intended. Internet Explorer 7 supports alpha channel transparency without needing extensions. No versions of Internet Explorer, however, support the gamma feature of PNG images, and the display of these images may be of the wrong tint.
PNG image files are generally smaller than GIF files of the same image quality, due to the more efficient compression techniques used in PNG encoding. PNG files can indeed be much larger than GIF files in situations where a GIF and a PNG file were created from a high-quality master image, as PNG is capable of storing more color depth and transparency information than GIF. However, for identical 8-bit (or lower) image data, PNG-format image files are almost always smaller than the equivalent GIF. Misinformation about PNG efficiency can generally be traced back to poor PNG support in older versions of some image manipulation programs, (for example Adobe Photoshop did not optimize PNGs for reduced color palettes by default).