About lessgif
lessgif is a set of free GIF tools that run entirely in your browser, built on an open-source GIF encoder of the same name.
Why another GIF tool?
GIF is an old format, but it is still the one that plays everywhere: chats, forums, email, documentation. Most GIF tools upload your file to a server and use encoders designed decades ago. lessgif does the work on your own device, so your files stay private, and its encoder was designed from scratch to make small GIFs.
How the encoder works
A GIF encoder normally runs separate steps: choose a palette and dither, mark pixels that didn't change as transparent, and, in "lossy" GIF tools, nudge pixels so the compression works better. Each step adds its own error on top of the last one's.
lessgif makes all of that one decision per pixel, always measured against the original colour. For each pixel it weighs continuing the current compressed run, keeping what the previous frame showed, or starting fresh with the nearest palette colour, and passes the remaining error on to the neighbouring pixels. Busy, textured areas are allowed more error than smooth ones, because noise hides in foliage but shows on a clear sky.
How it was measured
| Test | Result |
|---|---|
| Video to GIF, 363 film clips, against gifski 1.34 | 50% smaller (median) at the same SSIMULACRA2 score of 70; smaller on every clip |
| Re-compressing 281 GIFs, against gifsicle 1.94 lossy | 40% smaller (median) at the same score |
| Near-lossless re-compression | 12 to 16% smaller than gifsicle |
| Lossless (quality 100) | all 281 test GIFs reproduced exactly |
| Correctness | 5,000 random test cases decode pixel-exactly in Pillow, ffmpeg and Chromium |
SSIMULACRA2 is a perceptual metric: it scores how close a picture looks to the original. The benchmark scripts and the list of test clips are in the source repository, so anyone can rerun them.
Limits worth knowing
- At the same score, lessgif's GIFs show a little more fine grain in flat areas such as sky when you zoom in. At normal size they look alike. No blind viewing test has been done yet.
- The test material was film footage and GIFs made from it. Screen recordings, phone videos and GIFs from the web may shrink more or less.
- A GIF that has already been optimised hard may not get smaller. The compressor then tells you to keep the original.
- The browser keeps every frame in memory, so very long or very large clips are better done with the app.
Open source
The encoder, this website and the benchmark are open source under the MIT or Apache-2.0 license. Bug reports and ideas are welcome as issues on GitHub.