Compress a GIF

Runs in your browser. This tool does not upload your file.

What this tool does

This tool makes a GIF smaller by reducing the number of colors it uses. That is a lossy change: every pixel keeps its position and its transparency, but its color is approximated to the nearest color in a smaller palette. Nothing is resized, re-timed or re-ordered.

  1. It counts every color the frames actually paint.
  2. It builds a smaller palette — 256, 128 or 64 colors.
  3. It maps each pixel to the nearest color in that palette. Pixels that already match a palette entry exactly are left alone; the rest get a small ordered dither pattern, which is why smooth gradients stay smooth instead of turning into flat bands.
  4. It writes a new GIF with the same frames and timings.

What stays the same

For GIFs this version supports, the output keeps:

  • the screen size and every frame's rectangle
  • the number of frames, their order, and each frame's delay
  • each frame's disposal method
  • the loop count, and the identifier bytes of the loop block (a file that said ANIMEXTS1.0 still does)
  • supported comment blocks and recognized application blocks, kept byte for byte; unsupported block shapes are refused with a reason
  • the transparency mask: a pixel that was transparent still is, and one that was not still is not. (The transparent index number itself is recomputed for the new palette, so that number changes.)
  • a global color table, so the background color still means something

What changes

  • the colors: they are approximated, not preserved. On our fixed sample set (47 files) the P99 color error at the lowest level was 21.2 ΔE00, inside the guard of 25 the output is held to. The engine cannot go below 64 colors at all.
  • the palette size: 256, 128 or 64 colors.
  • possibly a fine dither texture at the lower levels — that is the trade for smoother gradients.
  • the file size: it gets smaller or it does not; see the three results above.

The size target

If you pick a target, the tool starts at the highest quality and steps down only as far as it must, never below 64 colors. Reaching the target is something it tries, not something it promises: some images cannot be brought under 256 KB by reducing colors alone, and it will say so rather than report a result it did not reach.

If your file is already under the target you choose, it is handed back unchanged. There is nothing to gain from re-encoding a file that already fits, and doing it would only cost quality.

How to compress a GIF to 256 KB

  1. Choose a GIF, or drop one on the page.
  2. Choose Discord (256 KB) in the target control — the same target the Discord preset button picks.
  3. Read the three readouts: the level it used, the output size, and the share of the original. The status line says whether the target was reached.
  4. Download the result, or choose another GIF.

A file that is already under 256 KB is handed back unchanged — there is nothing to gain from re-encoding it. If no level reaches the target, the page reports the smallest size it managed instead of a result it did not reach, and says that reducing colors alone was not enough.

When it says no

Some GIFs are not supported by this version, and it tells you which condition it hit:

  • a frame that is not governed by the graphic control block directly before it (E1)
  • a plain-text block sitting between a frame and its control block (E1)
  • no global color table at all (E2)
  • an extension from an application this tool does not recognise (E3)
  • a file that ends in the middle of a block (truncated)

Limits of this version

  • It does not resize, crop, re-time or change the frame rate. Those are different tools.
  • It does not export frames. For the pixels themselves, the GIF frame extractor hands each frame out as a PNG.
  • It does not compress without changing colors: there is no lossless mode here.
  • It does not work on every GIF — see the list above for the shapes it refuses.
  • The numbers on this page come from a fixed set of 47 files we generated and measured, at the three color counts this tool offers. Your GIF will behave differently, and that sample set is not a survey of real-world GIFs.

Questions

Is this lossless?

No. It reduces the number of colors, so colors are approximated. Pixels keep their positions and their transparency, and the structure of the GIF is preserved, but the picture is redrawn.

Will it always make my file smaller?

No, and it never promises a percentage. Among re-encoded global-dither candidates in our fixed sample set, outputs ranged from about 88.2% to 76.5% of the source. Files already under the target are returned unchanged.

What exactly is preserved?

Screen size, frame rectangles, frame count and order, delays, disposal methods, the loop count and its identifier bytes, supported comment blocks and recognized application blocks (byte for byte), the transparency mask, and a global color table. Unsupported block shapes are refused with a reason rather than passed through. The colors themselves are not preserved.

What is the dither pattern I can see at low color counts?

A small ordered pattern that mixes neighbouring palette colors so a gradient reads as a gradient instead of as flat bands. A visual review of the two candidate strategies at 64 colors chose this one because the alternative showed larger flat bands, and because on our sample set it added no flicker and cost about half a percentage point of file size.

What happens to transparency?

Which pixels are transparent does not change: the transparent mask is compared pixel by pixel between input and output. What changes is the index number that points at the transparent entry, because the palette changed.

Why will it not go below 64 colors?

Because it cannot go lower: the engine offers 256, 128 and 64 colors and clamps anything below that, so 64 is its floor. At 64 colors the worst color error across our fixed sample set is 21.2 ΔE00, inside the guard of 25 the output is held to.

What if 256 KB cannot be reached?

Then the page says so instead of reporting a result it did not reach, and gives the smallest size it managed. Reducing colors alone does not always bring a picture under 256 KB; the tool never claims otherwise. A file that is already under 256 KB is handed back unchanged. Cropping the GIF first can help — that is what the GIF cropper on this site is for.

Does compressing to 256 KB change the colors or the quality?

Yes. The picture is redrawn with fewer colors: the tool starts at 256 colors and steps down only as far as it must, and never below 64. On our fixed sample set of 47 files, the P99 color error at the lowest level was 21.2 ΔE00, inside the guard of 25 the output is held to. Positions, frame count, delays and the transparency mask stay the same.

Which GIFs are refused?

Frames not governed by their control block, a plain-text block between a frame and its control block, files with no global color table, extensions from unrecognised applications, and truncated files. Each refusal names the condition it hit.

Does my file get uploaded?

The compressor runs in your browser, and this tool does not upload your file. The page itself is downloaded from a server like any other web page.

Can I get the original colors back?

No. Keep your original file: the output is a new file, and the reduction is not reversible.