Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing of XMP and EXIF is inconsistent in 11.0.0 due to #8286 #8479

Open
maltelorbach opened this issue Oct 17, 2024 · 1 comment · May be fixed by #8483
Open

Writing of XMP and EXIF is inconsistent in 11.0.0 due to #8286 #8479

maltelorbach opened this issue Oct 17, 2024 · 1 comment · May be fixed by #8483

Comments

@maltelorbach
Copy link

maltelorbach commented Oct 17, 2024

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?

  • 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
@maltelorbach maltelorbach changed the title Writing of XMP and EXIF is now inconsistent due to #8286 Writing of XMP and EXIF is inconsistent in 11.0.0 due to #8286 Oct 17, 2024
@radarhere radarhere linked a pull request Oct 18, 2024 that will close this issue
@radarhere
Copy link
Member

I've created #8483 to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants