From 132b714618bdaaa5990acbd6a70e6c1969d6e60b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 14 Jul 2026 17:36:22 +1000 Subject: [PATCH 1/2] Remove duration and timestamp from info after seek --- Tests/test_file_webp_animated.py | 3 +++ src/PIL/WebPImagePlugin.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Tests/test_file_webp_animated.py b/Tests/test_file_webp_animated.py index 600448fb9e1..956139a88af 100644 --- a/Tests/test_file_webp_animated.py +++ b/Tests/test_file_webp_animated.py @@ -178,6 +178,9 @@ def test_seeking(tmp_path: Path) -> None: ts = dur * (im.n_frames - 1) for frame in reversed(range(im.n_frames)): im.seek(frame) + assert "duration" not in im.info + assert "timestamp" not in im.info + im.load() assert im.info["duration"] == dur assert im.info["timestamp"] == ts diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py index 63a48169182..129f8255dc1 100644 --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -86,6 +86,8 @@ def _getexif(self) -> dict[int, Any] | None: def seek(self, frame: int) -> None: if not self._seek_check(frame): return + self.info.pop("timestamp", None) + self.info.pop("duration", None) # Set logical frame to requested position self.__logical_frame = frame From d0da59b7311e9a3d62f504e52f77e28c7deee175 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 14 Jul 2026 22:06:07 +1000 Subject: [PATCH 2/2] Document WebP info properties on opened images --- docs/handbook/image-file-formats.rst | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index 6b38b7278e8..95c95e5155f 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -1376,6 +1376,36 @@ WebP Pillow reads and writes WebP files. Requires libwebp v0.5.0 or later. +Opening +~~~~~~~ + +The :py:meth:`~PIL.Image.open` method sets the following +:py:attr:`~PIL.Image.Image.info` properties: + +**background** + Background color of the canvas, as an RGBA tuple with values in + the range of (0-255). + +**loop** + The number of times the WEBP should loop. 0 means that it will loop forever. + +**icc_profile** + May not be present. The ICC color profile for the image. + +**exif** + May not be present. Raw EXIF data from the image. + +**xmp** + May not be present. Raw XMP data from the image. + +**duration** + Only present after the current frame is loaded. The time to display the current + frame of the WEBP, in milliseconds. + +**timestamp** + Only present after the current frame is loaded. The total duration of all previous + frames of the WEBP, in milliseconds. + .. _webp-saving: Saving