Why GIFs Only Support 256 Colors
The GIF format was designed in 1987 when 256 colors was considered generous for computer displays. It uses 8-bit indexed color: each pixel stores an index (0–255) that references a color in a lookup table (the palette). The palette holds up to 256 colors, each defined as an RGB triplet.
The key insight: those 256 colors can be any 256 colors from the full 16.7 million RGB color space. A GIF of a sunset can use 256 shades of orange, red, and purple. A GIF of a forest can use 256 shades of green. The challenge is choosing the right 256 colors for your specific content.
Why Palette Selection Matters
A generic "web-safe" palette uses a fixed set of 216 colors spread across the spectrum. For video content, this produces terrible results because the colors may not match your video at all.
A custom palette analyzes the actual pixels in your video and selects the 256 colors that best represent the content. The improvement is dramatic — colors look natural, gradients are smoother, and details are preserved.
Our converter uses FFmpeg's two-pass approach: first analyze the video to generate an optimal palette (palettegen), then apply that palette to create the GIF (paletteuse). This produces significantly better results than single-pass tools.
Palette Generation Methods
Full Mode (stats_mode=full)
Analyzes all pixels in all frames to build one global palette. Best for videos with diverse, changing content like film clips, action sequences, and music videos where colors vary across frames.
Diff Mode (stats_mode=diff)
Only counts pixels that change between frames. Better for videos with static backgrounds like screen recordings, presentations, and talking-head videos. Produces smaller files because it allocates more palette entries to the changing content and fewer to the unchanging background.
Single Mode (stats_mode=single)
Creates a new palette for every frame. Provides the highest possible quality since each frame gets an optimized palette, but produces larger files. Best for photographic content where color accuracy is critical.
Color Count Tradeoffs
| Colors | Quality | Size Savings | Best For |
|---|---|---|---|
| 256 | Best possible | Baseline | Photographic content |
| 128 | Barely different | 15–25% | Sweet spot for most content |
| 64 | Slight banding | 30–45% | Screen recordings |
| 32 | Noticeable posterization | 45–60% | Simple graphics only |
| 16 | Significant degradation | 60–75% | Logos, pixel art |
Dithering: Simulating Missing Colors
Dithering uses patterns of available colors to simulate colors not in the palette. It is the difference between harsh color banding and smooth-looking gradients.
- No dithering: maps each pixel to the nearest palette color. Fastest, smallest files, but shows visible banding on gradients. Best for flat-color content like logos and pixel art.
- Bayer (ordered): uses a deterministic crosshatch pattern. The regular pattern compresses well, making it the best choice when file size is critical. Slight visible pattern at close inspection.
- Floyd-Steinberg (error diffusion): distributes quantization error to neighboring pixels. Produces the most natural-looking results for photographic content. Larger files due to random-looking pixel patterns.
- Sierra2: enhanced error diffusion with a wider distribution kernel. Produces results between Floyd-Steinberg and Bayer in both quality and file size. Our recommended default.
Recommendations by Content Type
| Content | Palette Mode | Colors | Dithering |
|---|---|---|---|
| Screencast | diff | 128 | Bayer |
| Film clip | full | 256 | Sierra2 |
| Logo animation | full | 64 | None |
| Photography | single | 256 | Floyd-Steinberg |
Modern Alternatives with Better Color Support
If GIF's 256-color limitation is unacceptable for your content, consider these alternatives:
- WebP animation: 24-bit color (16.7M colors), full alpha transparency, 50–70% smaller than GIF. Supported by 97%+ of browsers.
- APNG: full PNG quality with 24-bit color and 8-bit alpha. Same browser support as WebP. Best when you need transparency with full color.
- MP4/WebM: millions of colors, vastly smaller files. Use
<video autoplay loop muted playsinline>on websites.
Compare all options in our animated formats comparison.