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

Keep new IFDs when converting EXIF to bytes #8635

Merged
merged 1 commit into from
Dec 29, 2024

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