Lossless GIF recompression via exhaustive search

(blog.arusekk.pl)

37 points | by ZacnyLos 5 hours ago ago

8 comments

  • gsquaredxc 2 hours ago ago

    > 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.

    • sltkr 30 minutes ago ago

      PyPy is an option too.

    • davidkwast an hour ago ago

      Nice advice

  • jjcm 18 minutes ago ago

    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.

  • Stitch4223 an hour ago ago

    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.

    • richard_todd an hour ago ago

      I agree, it would be way more interesting to see a table of original GIF sizes versus the improved size. I'm left wondering how bad the plain greedy version is on a typical image.

  • kernelbugs 3 hours ago ago

    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.

    • chrismorgan 2 hours ago ago

      > didn't realize there was a usecase for single frame GIFs anymore

      If the purpose is supporting NCSA Mosaic… I’m content to say that there isn’t. Definitely not “anymore”.