Skip to content
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

Do not create core image in TIFF seek() #8392

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Sep 18, 2024

def seek(self, frame: int) -> None:
"""Select a given frame as current image"""
if not self._seek_check(frame):
return
self._seek(frame)
# Create a new core image object on second and
# subsequent frames in the image. Image may be
# different size/mode.
Image._decompression_bomb_check(self._tile_size)
self.im = Image.core.new(self.mode, self._tile_size)

The core image instance does not need to be created here. It can be set to None instead, and the initialisation can delayed until load() (or more specifically, load_prepare()).

def load_prepare(self) -> None:
if self._im is None:
self.im = Image.core.new(self.mode, self._tile_size)

@radarhere radarhere changed the title Do not create core image in TiffImagePlugin seek(), when load() might not run Do not create core image in TIFF seek(), when load() might not run Sep 18, 2024
@radarhere radarhere changed the title Do not create core image in TIFF seek(), when load() might not run Do not create core image in TIFF seek() Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant