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
Convert subsequent GIF frames to RGB or RGBA #5857
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Nov 29, 2021
Closed
This was referenced Nov 29, 2021
radarhere
commented
Nov 29, 2021
@@ -340,12 +366,16 @@ def test_dispose_background(): | |||
def test_dispose_background_transparency(): | |||
with Image.open("Tests/images/dispose_bgnd_transparency.gif") as img: | |||
img.seek(2) | |||
px = img.convert("RGBA").load() | |||
px = img.load() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now already an RGBA image.
This was referenced Nov 30, 2021
Closed
Resolving 11 issues at once, must be a record! |
radarhere
added a commit
to radarhere/Pillow
that referenced
this pull request
Dec 6, 2021
This was referenced Jan 4, 2022
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1525
Resolves #1717
Resolves #1692
Resolves #1742
Resolves #2543
Resolves #2893
Resolves #4977
Resolves #5734
Resolves #5781
Resolves #5819
Resolves #5837
Each GIF frame can have its own palette, and each of those palettes can have up to 256 colors. So the second frame of a GIF image may have 512 colors, the third 768 colors, and so on.
However, Pillow keeps a GIF image as P (or L) mode as it loads new frames. P mode images can only have 256 colors at most.
This has lead to many issues complaining about colors in subsequent GIF frames.
This PR instead changes GIF images to RGB or RGBA once you seek to a subsequent frame.
Internally, this is done by simply converting the two P mode images to RGB(A), and then pasting one onto the other.
This finishes the thoughts I started in #3735. It also reverts part of #5333, since those changes are no longer necessary.