mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Merge pull request #7311 from k128/main
Read WebP duration after opening
This commit is contained in:
commit
39d866b17d
|
@ -233,5 +233,4 @@ class TestFileWebp:
|
||||||
im.save(out_webp, save_all=True)
|
im.save(out_webp, save_all=True)
|
||||||
|
|
||||||
with Image.open(out_webp) as reloaded:
|
with Image.open(out_webp) as reloaded:
|
||||||
reloaded.load()
|
|
||||||
assert reloaded.info["duration"] == 1000
|
assert reloaded.info["duration"] == 1000
|
||||||
|
|
|
@ -74,6 +74,9 @@ class WebPImageFile(ImageFile.ImageFile):
|
||||||
self.info["background"] = (bg_r, bg_g, bg_b, bg_a)
|
self.info["background"] = (bg_r, bg_g, bg_b, bg_a)
|
||||||
self.n_frames = frame_count
|
self.n_frames = frame_count
|
||||||
self.is_animated = self.n_frames > 1
|
self.is_animated = self.n_frames > 1
|
||||||
|
ret = self._decoder.get_next()
|
||||||
|
if ret is not None:
|
||||||
|
self.info["duration"] = ret[1]
|
||||||
self._mode = "RGB" if mode == "RGBX" else mode
|
self._mode = "RGB" if mode == "RGBX" else mode
|
||||||
self.rawmode = mode
|
self.rawmode = mode
|
||||||
self.tile = []
|
self.tile = []
|
||||||
|
@ -90,7 +93,7 @@ class WebPImageFile(ImageFile.ImageFile):
|
||||||
self.info["xmp"] = xmp
|
self.info["xmp"] = xmp
|
||||||
|
|
||||||
# Initialize seek state
|
# Initialize seek state
|
||||||
self._reset(reset=False)
|
self._reset()
|
||||||
|
|
||||||
def _getexif(self):
|
def _getexif(self):
|
||||||
if "exif" not in self.info:
|
if "exif" not in self.info:
|
||||||
|
@ -113,9 +116,8 @@ class WebPImageFile(ImageFile.ImageFile):
|
||||||
# Set logical frame to requested position
|
# Set logical frame to requested position
|
||||||
self.__logical_frame = frame
|
self.__logical_frame = frame
|
||||||
|
|
||||||
def _reset(self, reset=True):
|
def _reset(self):
|
||||||
if reset:
|
self._decoder.reset()
|
||||||
self._decoder.reset()
|
|
||||||
self.__physical_frame = 0
|
self.__physical_frame = 0
|
||||||
self.__loaded = -1
|
self.__loaded = -1
|
||||||
self.__timestamp = 0
|
self.__timestamp = 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user