I opened/created a new image with XMP and Exif data. I saved the image using save() without passing the XMP/Exif data.
What did you expect to happen?
In Pillow 10.x, the saved image would not contain any metadata (xmp, exif, ...) unless explicitly passed to save().
What actually happened?
In Pillow 11.0.0, the save image contains XMP metadata although I did not pass it to save().
8286 introduced writing XMP data and its behavior changed with earlier versions and is now inconsistent wrt to how writing exif data is handled. I'd expect either all metadata to be written by default or none.
I believe how the default value of xmp/exif are defined makes the difference:
from PIL import Image
im = Image.new("RGB", (128, 128))
im.info["xmp"] = b"some data"
im.info["exif"] = b"some more data"
im.save("img_with_metadata.jpg")
inter = Image.open("img_with_metadata.jpg")
if inter.info.get("xmp") == b"some data":
print("XMP data is present")
else:
print("XMP data is not present")
if inter.info.get("exif") == b"some more data":
print("EXIF data is present")
else:
print("EXIF data is not present")
What did you do?
I opened/created a new image with XMP and Exif data. I saved the image using
save()
without passing the XMP/Exif data.What did you expect to happen?
In Pillow 10.x, the saved image would not contain any metadata (xmp, exif, ...) unless explicitly passed to
save()
.What actually happened?
In Pillow 11.0.0, the save image contains XMP metadata although I did not pass it to
save()
.8286 introduced writing XMP data and its behavior changed with earlier versions and is now inconsistent wrt to how writing exif data is handled. I'd expect either all metadata to be written by default or none.
I believe how the default value of xmp/exif are defined makes the difference:
https://github.com/radarhere/Pillow/blob/6e2ebaae2d50302b58ab046257df492493e5e86e/src/PIL/JpegImagePlugin.py#L754
https://github.com/radarhere/Pillow/blob/6e2ebaae2d50302b58ab046257df492493e5e86e/src/PIL/JpegImagePlugin.py#L794
What are your OS, Python and Pillow versions?
Example
Running above code with Pillow 10.4.0:
With Pillow 11.0.0: