Skip to content

Do not load previous frame in ImageFile load() - #10304

Open
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:load
Open

radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:load

Conversation

@radarhere

@radarhere radarhere commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Similar to #10268

Pillow/src/PIL/ImageFile.py

Lines 310 to 319 in 69f0a52

def load(self) -> Image.core.PixelAccess | None:
"""Load image data based on tile list"""
if not self.tile and self._im is None:
msg = "cannot load this image"
raise OSError(msg)
pixel = Image.Image.load(self)
if not self.tile:
return pixel

While pixel is used if there is no tile, it isn't otherwise. If an image with multiple frames, this has the effect of loading a potentially dirty palette and preparing pixel access unnecessarily.

This branch has not been deployed

No deployments
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.

1 participant