From 3407f765cc81f5be9046fe51c36f7cf1dec6790b Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 28 Feb 2025 10:28:48 +1100 Subject: [PATCH] Document using encoderinfo on subsequent frames from #8483 --- src/PIL/Image.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 6a2aa3e4c..d5bfda40e 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2475,7 +2475,21 @@ class Image: format to use is determined from the filename extension. If a file object was used instead of a filename, this parameter should always be used. - :param params: Extra parameters to the image writer. + :param params: Extra parameters to the image writer. These can also be + set on the image itself through ``encoderinfo``. This is useful when + saving multiple images:: + + # Saving XMP data to a single image + from PIL import Image + red = Image.new("RGB", (1, 1), "#f00") + red.save("out.mpo", xmp=b"test") + + # Saving XMP data to the second frame of an image + from PIL import Image + black = Image.new("RGB", (1, 1)) + red = Image.new("RGB", (1, 1), "#f00") + red.encoderinfo = {"xmp": b"test"} + black.save("out.mpo", save_all=True, append_images=[red]) :returns: None :exception ValueError: If the output format could not be determined from the file name. Use the format option to solve this.