Closed
Description
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:
What are your OS, Python and Pillow versions?
- OS: Ubuntu
- Python: 3.12
- Pillow: 10.4.0 / 11.0.0
Example
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")
Running above code with Pillow 10.4.0:
--------------------------------------------------------------------
Pillow 10.4.0
Python 3.12.1 (main, Jan 4 2024, 15:28:04) [GCC 11.4.0]
--------------------------------------------------------------------
XMP data is not present
EXIF data is not present
With Pillow 11.0.0:
--------------------------------------------------------------------
Pillow 11.0.0
Python 3.12.1 (main, Jan 4 2024, 15:28:04) [GCC 11.4.0]
--------------------------------------------------------------------
>>> XMP data is present
>>> EXIF data is not present