Skip to content

cgifsave: allow to apply maxerror optimization to frames with alpha channel #2778

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

Merged
merged 1 commit into from
May 7, 2022

Conversation

dloebl
Copy link
Contributor

@dloebl dloebl commented Apr 26, 2022

As of now, the maxerror parameter cannot be applied to animated GIFs with an active alpha channel.
Make it possible to detect cases where the alpha channel component of the current frame matches with the one from the frame before.
In these cases it is possible to use the transparency index for the maxerror optimization instead of for the alpha channel.
This pull request helps to further improve the file size of animated GIFs (for reference: #2576).

Example:
$ vips copy test.gif[n=-1] old.gif[maxerror=16]
$ vips copy test.gif[n=-1] new.gif[maxerror=16]
$ gifsicle -O3 test.gif -o gifsicle.gif
Results:
du -h *.gif
1.0M new.gif
5.8M gifsicle.gif
6.1M test.gif
9.8M old.gif
150592639-fcf2489c-c43e-478e-a66f-83fb3a9a98aa

@jcupitt
Copy link
Member

jcupitt commented May 7, 2022

This looks great @dloebl, let's merge. Thank you for doing this, and sorry it took me a while :(

I think the asan failure is a temporary clang issue.

@jcupitt jcupitt merged commit cb55fdc into libvips:master May 7, 2022
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

Successfully merging this pull request may close these issues.

2 participants