Introduction
GIF was introduced by CompuServe in 1987 (version 87a) and extended in 1989 (version 89a). Each frame holds up to 256 colours from a palette, compressed without loss using LZW. Version 89a added transparency, frame delays and comments, which together made GIF the format for short looping animations on the web.
The LZW patent held by Unisys led to the creation of PNG in the 1990s. The patent expired in 2003 and 2004, and GIF remains widely supported.
A .gif file dropped on any page of this site opens in the explorer, which
shows the picture, plays an animation, and lets the blocks and the LZW codes be explored
byte by byte.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.GIF | Graphics Interchange Format (GIF87a) | The first GIF: palette images on a logical screen, LZW compressed, no extensions. | Open |
.GIF | Graphics Interchange Format (GIF89a) | Palette images of up to 256 colours, LZW compressed, often animated. | Open |
GIF87a
The first version. A file holds a logical screen, an optional global colour table and one or more images, each placed somewhere on the screen with its own optional colour table. It has no transparency, no timing and no comments.
The file starts with GIF87a (47 49 46 38 37 61).
GIF89a
The current version. It keeps the 87a layout and adds extension blocks: the graphic
control extension, which gives a frame its delay, disposal method and transparent
colour, plus comment, plain text and application extensions. Looping animations use
the NETSCAPE2.0 application extension.
The file starts with GIF89a (47 49 46 38 39 61). Many
programs still write GIF87a when a file uses none of the 89a
additions.
Not described
The reference pages for both versions leave some things out, and the viewer does not do everything; the full lists are on the GIF89a and GIF87a pages.
Known, not yet covered
- Reference: application extensions other than NETSCAPE2.0, ICC and XMP, which open source readers such as ImageMagick handle (Extensions).
- Reference: which short delays browsers lengthen, and the rest of Firefox’s animation rules (its loop count handling was checked): browser source settles them; not checked (Animation).
- Viewer: plain text is listed and not drawn; ICC profiles and XMP packets are offered as files and not interpreted or applied.
- Viewer: the animation is played by the browser and the user input flag is not applied; the pixel aspect ratio and background colour are shown and not applied.
Unknown
- Reference and viewer: disposal methods 4 to 7, extension labels other than F9, FE, 01 and FF, and plain text in real files: the specification leaves them undefined or open and no real file here has them, so they rest on built files. The viewer shows unknown extensions as labelled bytes.
- Reference and viewer: damaged data and colour numbers past a table: the specification is silent and decoders differ. The viewer leaves undecoded pixels transparent, with a note.
Links
Software
- GIMP – free image editor that opens, edits and saves GIFs, including animations as layers (Windows, macOS, Linux)
- Adobe Photoshop – image editor that opens GIFs and exports them, with frames from its timeline (Windows, macOS)
- Photopea – image editor in the browser that opens and saves GIF (web browser)
- Ezgif – online tool for making, cutting and optimising animated GIFs (web browser)
- Gifsicle – command-line tool that edits and optimises GIF animations (Windows, macOS, Linux)
- ImageMagick – command-line tools that convert to and from GIF (Windows, macOS, Linux)
- IrfanView – image viewer that plays and converts GIFs (Windows)
- XnView MP – image viewer and batch converter (Windows, macOS, Linux)
Developers
Reference
- GIF87a specification – CompuServe’s original specification, 1987
- GIF89a specification – CompuServe’s revised specification, 1990