Skip to content

Commit

Permalink
In seek(), create core image at size needed for loading
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 18, 2024
1 parent a92dca6 commit 629f5be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,8 @@ def seek(self, frame: int) -> None:
# 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.size)
self.im = Image.core.new(self.mode, self.size)
Image._decompression_bomb_check(self._tile_size)
self.im = Image.core.new(self.mode, self._tile_size)

def _seek(self, frame: int) -> None:
self.fp = self._fp
Expand Down Expand Up @@ -1276,8 +1276,8 @@ def load(self) -> Image.core.PixelAccess | None:
return super().load()

def load_prepare(self) -> None:
if self._im is None and self._will_be_transposed:
self.im = Image.core.new(self.mode, self.size[::-1])
if self._im is None:
self.im = Image.core.new(self.mode, self._tile_size)
ImageFile.ImageFile.load_prepare(self)

def load_end(self) -> None:
Expand Down Expand Up @@ -1421,9 +1421,9 @@ def _setup(self) -> None:
if not isinstance(xsize, int) or not isinstance(ysize, int):
msg = "Invalid dimensions"
raise ValueError(msg)
self._tile_size = xsize, ysize
orientation = self.tag_v2.get(ExifTags.Base.Orientation)
self._will_be_transposed = orientation in (5, 6, 7, 8)
if self._will_be_transposed:
if orientation in (5, 6, 7, 8):
self._size = ysize, xsize
else:
self._size = xsize, ysize
Expand Down

0 comments on commit 629f5be

Please sign in to comment.