Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Nov 24, 2023

When saving multiple GIF frames, Pillow trims identical edges of each new frame. This PR goes further, setting the pixels that are not new in the next frame as transparent if Pillow is optimizing. If there is no transparency, try and allocate one.

I started work on this after seeing #6832 (comment). If I remove optimize=False from that code, then without this change the file size is 21.5mb. With this change, the file size is 8.1mb.

For a less dramatic example, the output of #617 (comment) is reduced from 408kb to 345kb

Because the only difference in output should be filesize, there are no new tests to demonstrate correctness. I have added a test to cover an exception caught if trying to add transparency when there is no room in the frame.

@alanhamlett
Copy link

Could this be causing the ValueError in #7777?

@radarhere
Copy link
Member Author

radarhere commented Feb 4, 2024

Yes, this would be the cause - but rather than just undoing this change, it would be better to adjust it, to both reduce filesize and to fix your problem. The quickest way of understanding how to do that would be for you to post a self-contained example of your problem in that issue.

@radarhere
Copy link
Member Author

#7777 was resolved by #7779

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants