Skip to content

Commit

Permalink
reload Image.core the same way as in TiffImagePlugin(PIL 11+) (#294)
Browse files Browse the repository at this point in the history
* added reload `Image.core` the same way as in TiffImagePlugin(PIL 11+)
* always reload "Image.core" between frames

Signed-off-by: Alexander Piskun <[email protected]>

---------

Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 authored Oct 6, 2024
1 parent 98aa122 commit c74a855
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pillow_heif/as_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def seek(self, frame: int):
return
self.__frame = frame
self._init_from_heif_file(frame)

if pil_version[:3] != "10.":
# Pillow 11.0+
# We need to create a new core image object on second and
# subsequent frames in the image. Image may be different size/mode.
# https://github.com/python-pillow/Pillow/issues/8439
self.im = Image.core.new(self._mode, self._size) # pylint: disable=too-many-function-args

_exif = getattr(self, "_exif", None) # Pillow 9.2+ do no reload exif between frames.
if _exif is not None and getattr(_exif, "_loaded", None):
_exif._loaded = False # pylint: disable=protected-access
Expand Down

0 comments on commit c74a855

Please sign in to comment.