Introduction
GIF87a is the first version of GIF, published by CompuServe in 1987 so that pictures could be shared across the different computers that used its online service. A file holds a logical screen and one or more images placed on it, each with up to 256 colours from a palette and compressed without loss using LZW.
It has no transparency, no frame timing and no comments; those came with
GIF89a. Programs still write
GIF87a files when a picture needs none of the later additions.
Structure
The file starts with a 6-byte header, GIF87a, and a 7-byte logical
screen descriptor giving the canvas size (little-endian), the colour resolution and
whether a global colour table follows. Then come the images, each introduced by
2C, and the trailer 3B that ends the file.
Each image has a 10-byte descriptor giving its position and size on the screen, an optional local colour table, the LZW minimum code size and the compressed data in sub-blocks: a length byte of up to 255 followed by that many bytes, ending with a zero-length sub-block.
0HeaderGIF87a6 bytes6Logical screen descriptor width, height, flags, background colour7 bytes13Global colour table 3 bytes per colour, optional6 to 768 bytes…Images repeated for each imagevaries2CImage descriptor position, size, flags10 bytes…Local colour table optional, then the LZW data sub-blocksvaries
…Trailer3B1 byte
Telling it apart
The file starts with GIF87a (47 49 46 38 37 61). A
GIF89a file starts with GIF89a
and may hold extension blocks, introduced by 21, between its images.
Variants
- Graphics Interchange Format (GIF87a) – the first GIF: palette images on a logical screen, with no extensions
- Graphics Interchange Format (GIF89a) – the current GIF, with extensions for transparency, timing and animation
Links
Software
- GIMP – free image editor that opens, edits and saves GIF (Windows, macOS, Linux)
- Adobe Photoshop – image editor that opens and exports GIF (Windows, macOS)
- Photopea – image editor in the browser that opens and saves GIF (web browser)
- Gifsicle – command-line tool that edits and optimises GIF files (Windows, macOS, Linux)
- ImageMagick – command-line tools that convert to and from GIF (Windows, macOS, Linux)
- IrfanView – image viewer that opens and converts GIF (Windows)
- XnView MP – image viewer and batch converter (Windows, macOS, Linux)
Developers
Reference
- GIF87a specification – CompuServe’s original specification, 1987