Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Tests/test_file_webp_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions docs/handbook/image-file-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/PIL/WebPImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading