Lossless GIF recompression via exhaustive search
ZacnyLos
61 points
15 comments
June 23, 2026
Related Discussions
Found 5 related stories in 125.7ms across 11,417 title embeddings via pgvector HNSW
- JPEG Compression 7777777phil · 20 pts · March 14, 2026 · 59% similar
- RawTree Adaptive Compression Codec stacyz · 11 pts · June 15, 2026 · 53% similar
- TurboQuant: Redefining AI efficiency with extreme compression ray__ · 509 pts · March 25, 2026 · 49% similar
- Apply video compression on KV cache to 10,000x less error at Q4 quant polymorph1sm · 16 pts · March 22, 2026 · 48% similar
- Journey to JPEG XL: open-source experiments shaped the future of image coding ledoge · 60 pts · June 03, 2026 · 47% similar
Discussion Highlights (6 comments)
kernelbugs
Cool effort! I appreciated the background into the why, as initially I thought this would have to do with optimizing animated GIFs and didn't realize there was a usecase for single frame GIFs anymore.
gsquaredxc
> Here I should note that Python is not the best choice for CPU-bound software. I want to take the opportunity to learn Zig. For optimizing CPU-bound operations in Python, there’s some low hanging fruit with numba. I would recommend this as a 5-minute solution to you limiting your algorithm because regular Python is too slow. I regularly tell people that if their Python program is slow enough to take several minutes, you could probably learn numba before it finishes.
Stitch4223
Love the goal of supporting ancient browsers. What I’m missing in the article about images is images. For example the achieved results and some table of the amount of space saved using the compression methods described. Nonetheless interesting read.
jjcm
Neat. I tested it and here were my results: ffmpeg conversion: 1,515 bytes, 0.05s zgif conversion: 1,479 bytes, 90.1s I used cursor to port it to rust as well, and it got the conversion time down to 20s. Still likely not worth it as even with the rust port it's a 400x increase in processing time (that scales exponentially) for a ~2% decrease in size.
BigTTYGothGF
> We need to be careful here, because finding the actual best compression for an arbitrary format can be equivalent to solving the halting problem. I don't see why that would be relevant here. The goal is to find the best compression of a given source among all possible DEFLATE streams, not to find the best compression of a given source among all possible ways to compress data. There are only so many DEFLATE streams shorter than the original source, you "simply" try them all, and then you've halted. That said: > Now, Zopfli is the software that performs an exhaustive search across all possible syntactically valid streams Maybe I don't understand LZ77 as well as I thought, but surely the search space is way too big to exhaust?
teddyh
For PNG, there’s ”pngcrush”: < https://pmt.sourceforge.io/pngcrush/ >