What Is a GIF? How the Format Works and Why It's Still Everywhere
GIF stands for Graphics Interchange Format, an image format CompuServe introduced in 1987. A GIF can hold a single image or a sequence of frames that play as a short, silent, looping animation. It's limited to 256 colors per frame and its files are large, but it plays almost everywhere without a video player, which is why it's still so common.
A short history
- 1987, GIF87a. CompuServe released the format to share images across different computers over slow connections.
- 1989, GIF89a. The updated spec added frame delays, transparency and other extensions. Animation was possible, but rarely used at first.
- Mid-1990s, looping. Netscape Navigator added an extension that tells the browser to repeat the animation. That's the endless loop people now associate with GIFs.
- Patent dispute. GIF's compression method, LZW, was patented, and licensing fees in the late 1990s pushed developers toward PNG. The patents expired in the early 2000s.
The name's pronunciation is still argued about. The format's creator says it with a soft G, like "jif". Plenty of people use a hard G. Both are understood.
How a GIF works
Frames
An animated GIF is a list of images stored one after another. Each frame can cover the whole canvas or just a small rectangle that changed since the last frame. Each frame also has a disposal method that tells the viewer what to do before drawing the next one: leave it, clear it, or restore what was there before.
Palettes
Each frame uses a palette of up to 256 colors. Every pixel is stored as a number pointing to one of those colors. That works well for logos and cartoons but poorly for photos, where smooth gradients need thousands of shades. To fake the missing colors, encoders use dithering, a pattern of mixed pixels that looks grainy up close.
One palette entry can be marked as transparent. Transparency is on or off per pixel, with no partial opacity.
Delays
Each frame stores how long to stay on screen, in hundredths of a second. A delay of 10 means 0.1 seconds, or 10 frames per second. Most browsers treat very short delays (0 or 1) as about 0.1 seconds, which is why some GIFs can't go faster. The guide on changing GIF speed covers this.
Why GIFs are so big
GIF compression is lossless and works on rows of pixels. It has no idea that two frames look almost the same, unlike video codecs, which only store what moved. So a few seconds of GIF often costs as much as a much longer video.
| Factor | Effect on size |
|---|---|
| Dimensions | Doubling width and height roughly quadruples the size |
| Frame count | More frames, more data, almost linearly |
| Colors and noise | Dithering and grain compress badly |
| Motion | Camera movement changes every pixel on every frame |
You can shrink a GIF a lot by cutting dimensions and frames, then applying lossy compression and fewer colors. The GIF compressor does the last two in one step. See how to compress a GIF without losing quality for the full process.
Why GIFs are still everywhere
- They play anywhere. Email clients, chat apps, forums, documentation sites and old browsers display GIFs without a video player or codec.
- They behave like images. A GIF autoplays, loops, and needs no controls or user tap.
- No sound to worry about. Silent by design, so they never surprise anyone.
- Easy to make and share. Almost every app can produce and accept them.
When to use something else
Many "GIFs" you see on large sites are actually MP4 or WebP files presented like GIFs. Video is usually several times smaller with better color.
- On your own website, use a looping, muted MP4 or animated WebP. Convert with the GIF to MP4 converter.
- For full color or soft transparency, use animated WebP or APNG. See WebP vs GIF vs APNG.
- For email, chat and anywhere video isn't allowed, GIF is still the safe choice.
For a deeper comparison of the two most common choices, read GIF vs MP4.