Repository navigation
Copy image when saving in GifImagePlugin - #1231
Merged
Merged
Conversation
Member
Author
|
I also found that when an Image is copied, the ImagePalette remains the same instance. Rather than sharing a resource between two images, I've changed it to copy ImagePalette as well. |
1 similar comment
wiredfool
added a commit
that referenced
this pull request
Jun 16, 2015
Copy image when saving in GifImagePlugin
This file contains hidden or 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
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.
#718 describes how saving an image in the GIF format can modify the palette of the original.
GifImagePlugin's getheader method has the comment 'create the new palette if not every color is used'. So that's why the image passed into getheader is modified.
The solution would seem to be to copy the image before passing it in.
However, this fails a few tests, because the image instance that was being checked against is no longer modified in sync with the saved file. Essentially, these tests should have been failing. I've changed the checks to similar rather than equal.
I also modified the tests affected to use copy() to try and avoid this way of sneaking past the tests in the future.