Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #8634

The following code doesn't currently keep the new IFD tag when converting to bytes.

from PIL import Image
exif = Image.Exif()
ifd = exif.get_ifd(0x8769)
ifd[36864] = b"0220"
exif.tobytes()

This is because the new IFD is added to exif._ifds, but not exif._data. It makes sense to not save it to exif._data, because a tag value for the IFD would indicate the IFD offset, which only has meaning in byte format. However, exif._ifds isn't checked when converting to bytes, so the new IFD is forgotten.

This PR fixes that.

@hugovk hugovk merged commit 171531c into python-pillow:main Dec 29, 2024
49 checks passed
@radarhere radarhere deleted the exif_ifd branch December 29, 2024 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loss of Exif IFD attributes when saving new JPEG image

2 participants