Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize GIFs #17

Open
gjoseph92 opened this issue Feb 15, 2023 · 1 comment
Open

Optimize GIFs #17

gjoseph92 opened this issue Feb 15, 2023 · 1 comment

Comments

@gjoseph92
Copy link
Owner

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.

@gjoseph92
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant