Optimize GIFs
gjoseph92 opened this issue · 1 comments
The GIFs we create are really big. Like easily 10s of MBs.
I think that's because every frame is stored in full. You can compress GIFs by storing each frame as a delta, so only parts of the image that have changed are re-drawn.
See https://stackoverflow.com/q/42698983/17100540 (no answers). The last answer to this question https://stackoverflow.com/q/24688802/17100540 references a gifmaker.makedelta
function, which doesn't seem to exist anymore, but maybe I found a version of in https://github.com/wnyc/PIL/blob/90b8b064178c9c0bd37d348ff2a45fd380e7149e/Scripts/gifmaker.py?
Could possibly be interesting to look at what gifsicle does: https://github.com/kohler/gifsicle/blob/master/src/optimize.c. I imagine something simpler would be possible to do pretty easily with NumPy/PIL.
Just came across https://github.com/ImageOptim/gifski, which might be an easier option to integrate with. Could probably build it into a wheel relatively easily with maturin.