WEBPery

GIF

.gif

Lossless 256-colour format from 1987 supporting animation. Limited to 1-bit transparency and inefficient versus modern alternatives.

rasterlosslessTransparencyAnimation100% browser support

Origin and cultural endurance

GIF (Graphics Interchange Format) was introduced by CompuServe in 1987 — making it one of the oldest image formats still in active use on the web. Its design priorities reflected its era: small files for slow modem connections, a fixed 256-colour palette, and lossless compression via LZW.

Technically, GIF has been superseded for almost every purpose. PNG handles static lossless graphics with full 24-bit colour. WebP, AVIF, and video formats handle animation with dramatically smaller files. And yet GIF remains the universal format for short looping animations — meme distribution, reaction images, social media — because no replacement has matched its frictionless cultural ubiquity.

This is the GIF paradox: technically obsolete, culturally indispensable.

Container structure

A GIF file consists of:

  • Header — magic bytes GIF87a or GIF89a identifying the version.
  • Logical Screen Descriptor — dimensions and background colour.
  • Global Colour Table — up to 256 RGB triplets (the palette).
  • One or more Image Blocks — each containing local screen descriptor, optional local colour table, and LZW-compressed pixel data.
  • Optional extension blocks — for animation timing, comments, application-specific data.
  • Trailer — terminating byte.

Animation works via the 89a extension. Each frame is its own image block with its own local colour table (if needed). Extension blocks specify per-frame delay times and disposal methods (whether the previous frame's pixels are kept, cleared, or restored).

LZW compression and the patent saga

GIF uses LZW (Lempel-Ziv-Welch) compression — a dictionary-based algorithm that finds repeated byte sequences and replaces them with references to a growing dictionary.

LZW was patented by Sperry in 1983 and acquired by Unisys. For years, web developers assumed GIF was freely usable. In late 1994, Unisys announced it would enforce its patent against GIF encoder vendors. The web community responded by creating PNG, which used the royalty-free DEFLATE algorithm.

The LZW patent expired in the United States in 2003 and in most other jurisdictions by 2004. By then, PNG had taken over for static lossless graphics. GIF remained dominant for animation, and that role has persisted long past the patent's expiry.

Palette limitation

GIF supports only 256 colours per image (per frame, in animations). This is the format's defining technical limitation.

For photographic content, 256 colours is nowhere near enough. A photo encoded as GIF requires aggressive colour quantisation (dithering) and shows visible banding and pattern artefacts. Photographs are the wrong content for GIF.

For graphics with limited palettes — logos, icons, simple illustrations — 256 colours is often plenty. GIF was the right format for these cases until PNG arrived. Today, PNG and lossless WebP both handle this content with better compression and full colour depth.

Binary transparency

GIF supports 1-bit transparency: each pixel is either fully transparent or fully opaque. There is no gradient transparency, no anti-aliasing across alpha. This is why GIF icons typically have jagged "matte" edges where transparency meets background.

PNG's 8-bit alpha solved this problem in 1996. WebP and AVIF also offer full alpha. For any content where edge quality matters, GIF is the wrong choice.

Animation

The one technical feature GIF still does well, in cultural terms, is animation.

Each frame can have its own colour palette, its own delay (in 1/100ths of a second), and its own disposal method (what happens to the previous frame's pixels when the new frame is shown). The animation can loop a specified number of times or loop forever (the typical case).

For a short looping animation, an animated GIF is universally embeddable. Every chat client, every social platform, every messaging app, every browser, every email client displays animated GIFs natively. No other animated format has that reach.

Why GIF persists despite being technically obsolete

The replacement landscape:

  • Animated WebP — 30–60% smaller files, full colour, full alpha. Supported in every browser that supports static WebP (~97% of traffic). Adoption blocker: not natively supported in many older chat clients, Slack, Discord embeds (which usually transcode to GIF anyway), Microsoft Teams, and most legacy email clients.
  • Animated AVIF — even smaller files than animated WebP. Adoption blocker: same as WebP plus slightly slower decode.
  • Short MP4 / WebM video — dramatically smaller again. Adoption blocker: many platforms treat video and image as fundamentally different content types, breaking the "drop a GIF in" workflow.
  • APNG — bit-perfect lossless animation. Adoption blocker: file sizes comparable to GIF, no compression advantage to justify migration.

The pattern is consistent: technically superior alternatives exist, but none has matched GIF's universal embed-and-it-just-works property.

For ecommerce, marketing, and web performance contexts, this calculus is different. Animated WebP wins decisively when you control delivery (your own site, your own CDN). The GIF persistence is specifically about distribution beyond your own systems.

Modern relevance

GIF remains the right choice for:

  • Reactions and memes shared in messaging apps.
  • Cultural content distributed across heterogeneous platforms.
  • Embedded animations in older email newsletters where animated WebP support is unreliable.
  • Backwards-compatible animation when you cannot guarantee modern browser support.

GIF is the wrong choice for:

  • Photographic content (palette limitation produces visible banding).
  • Static graphics (PNG or WebP win on compression and quality).
  • Performance-sensitive animations on your own website (animated WebP wins on file size).
  • Any content with transparency that needs anti-aliased edges (no 8-bit alpha).

When to convert GIF to WebP

If you control the delivery (your own website, your own app), converting animated GIFs to animated WebP is almost always a win. Typical results:

  • 30–60% smaller file size.
  • Same animation timing and frame count.
  • Better visual quality (full colour, full alpha).

The migration pattern is straightforward: convert the GIF to animated WebP, ship as the primary source with the GIF as fallback in <picture>:

<picture>
  <source srcset="/anim/reaction.webp" type="image/webp" />
  <img src="/anim/reaction.gif" alt="..." width="480" height="270" />
</picture>

The browser uses animated WebP when supported and falls back to GIF otherwise. For the conversion itself, see GIF to WebP.

If the GIF will be re-shared off your platform (chat clients, Slack, Discord), keep the GIF original. Recipients' platforms may not handle animated WebP.

Conversion tooling

  • gif2webp — the official tool for converting GIF to animated WebP. Part of the libwebp utility set.
  • ImageMagick — supports conversion in both directions but produces less optimised output than gif2webp.
  • Sharp (Node.js) — handles GIF reading and WebP writing in build pipelines.
  • FFmpeg — for converting GIFs to MP4 or WebM for further size reduction (where video is acceptable).
# Standard GIF to animated WebP conversion
gif2webp -q 80 -m 6 input.gif -o output.webp

# Lossless WebP from GIF (preserves the source palette exactly)
gif2webp -lossless input.gif -o output.webp

File size benchmarks

Rough rules for typical GIF content:

GIF sizeAnimated WebP equivalent (q=80)Reduction
500 KB200–300 KB40–60%
2 MB700–1100 KB45–65%
5 MB1.5–2.5 MB50–70%
12 MB3–5 MB60–75%

Larger GIFs see larger relative savings because animated WebP's prediction-based compression scales better with file size than GIF's per-frame LZW.

Implementation patterns

For shipping animated content with progressive enhancement:

<picture>
  <source srcset="/anim/loop.webp" type="image/webp" />
  <img
    src="/anim/loop.gif"
    alt="..."
    width="640"
    height="360"
    loading="lazy"
    decoding="async"
  />
</picture>

For very long animations or anything that could reasonably be a video, an MP4 or WebM source is usually the right answer:

<video autoplay loop muted playsinline width="640" height="360" poster="/anim/poster.webp">
  <source src="/anim/loop.webm" type="video/webm" />
  <source src="/anim/loop.mp4" type="video/mp4" />
</video>

A 10-second animation as MP4 is typically 1/10th the size of the same animation as animated WebP, which is itself smaller than GIF.

Converters

  • GIF to WebP — convert animated GIFs to animated WebP
  • WebP to GIF — convert WebP back to GIF for sharing where GIF is required

Further reading