Skip to content

Commit 5edab79

Browse files
radarhereeyedav
authored andcommitted
Document using encoderinfo on subsequent frames from python-pillow#8483
1 parent 3e8162b commit 5edab79

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/PIL/Image.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2475,7 +2475,21 @@ def save(
24752475
format to use is determined from the filename extension.
24762476
If a file object was used instead of a filename, this
24772477
parameter should always be used.
2478-
:param params: Extra parameters to the image writer.
2478+
:param params: Extra parameters to the image writer. These can also be
2479+
set on the image itself through ``encoderinfo``. This is useful when
2480+
saving multiple images::
2481+
2482+
# Saving XMP data to a single image
2483+
from PIL import Image
2484+
red = Image.new("RGB", (1, 1), "#f00")
2485+
red.save("out.mpo", xmp=b"test")
2486+
2487+
# Saving XMP data to the second frame of an image
2488+
from PIL import Image
2489+
black = Image.new("RGB", (1, 1))
2490+
red = Image.new("RGB", (1, 1), "#f00")
2491+
red.encoderinfo = {"xmp": b"test"}
2492+
black.save("out.mpo", save_all=True, append_images=[red])
24792493
:returns: None
24802494
:exception ValueError: If the output format could not be determined
24812495
from the file name. Use the format option to solve this.

0 commit comments

Comments
 (0)