Repository navigation
Do not write IFD1 as a tag when converting EXIF to bytes - #10188
Merged
Merged
Conversation
Member
|
Hmm. If I adjust the test to def test_exif_ifd1(self) -> None:
with Image.open("Tests/images/flower.jpg") as im:
exif = im.getexif()
before_ifd1_read = exif.tobytes()
assert exif.get_ifd(ExifTags.IFD.IFD1) == {
513: 2036,
514: 5448,
259: 6,
296: 2,
282: 180.0,
283: 180.0,
}
# Assert that reading IFD1 does not change the data
assert exif.tobytes() == before_ifd1_readit fails? |
Contributor
Author
|
Good point, it does. That one isn't IFD1 though: |
radarhere
reviewed
Oct 12, 2026
radarhere
enabled auto-merge (squash)
October 12, 2026 10:17
radarhere
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
ExifTags.IFD.IFD1whenExif.tobytes()copies_ifdsinto IFD0test_exif_ifd1to convert to bytes after reading IFD1Since 11.1.0, looking at the thumbnail IFD and then saving with the same
Exifinstance fails:get_ifd()stores IFD1 in_ifdsunder its enum value, -1, and the loop added in #8635 writes every_ifdsentry that isn't a key in theExifinstance into IFD0, so -1 ends up being packed as a tag number. IFD1 wasn't written bytobytes()before that either, so I've just left it out of the loop. 11.0.0 saves the snippet above fine.The EXIF, JPEG, MPO, PNG, TIFF and WebP metadata tests pass locally.
Didn't find this reported. #10177 was the nearest recent change, but that's a
KeyErrorinsideget_ifd()for Interop and MakerNote. I did notice the same loop puts 0xA005 and 0x927C into IFD0 after those two are read, without raising anything, and I haven't touched that here.