Repository navigation
Do not load palette in ImageFile load_prepare() - #10268
Merged
Merged
Conversation
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.
Pillow/src/PIL/ImageFile.py
Lines 462 to 468 in 60dcd68
This "create palette (optional)" code has been there since PIL. The effect would be to call
Image.load()and potentially copy the palette from Python to CPillow/src/PIL/Image.py
Lines 984 to 987 in 60dcd68
At minimum, it would be better to change the ImageFile condition to match the
self.palette.dirtycondition.However, I don't think the palette needs to be copied here at all. None of our decoders use the C palette. It would be surprising if they read P data only to immediately transform it. A dirty palette can be left for the end of ImageFile's
load()to handle.Pillow/src/PIL/ImageFile.py
Line 460 in 60dcd68
So I suggest removing the call to
Image.Image.load(self).