Fixed conversion of AVIF image rotation property to EXIF orientation#8866
Merged
hugovk merged 2 commits intopython-pillow:mainfrom Apr 4, 2025
Merged
Conversation
This implements a fix for the issue identified in AOMediaCodec/libavif#2727 and fixed in AOMediaCodec/libavif#2729. The code to convert irot and imir properties to EXIF orientation when decoding AVIF images in Pillow was repurposed from libavif, so it suffers the same bug.
Member
|
Would it be possible to add a test? |
Contributor
Author
|
Oh, of course. Yes, I'll add one. |
fdintino
commented
Apr 3, 2025
| if orientation == 1: | ||
| assert "exif" not in reloaded.info | ||
| else: | ||
| assert reloaded.getexif()[274] == orientation |
Contributor
Author
There was a problem hiding this comment.
This assertion fails before this change for orientations 6 and 8.
Member
There was a problem hiding this comment.
We can include this new assertion if you like, but actually, the next line
assert reloaded.info["exif"] == exif_dataalready fails with the new parameters. This is because the next line is checking the full EXIF data, not just the orientation.
Contributor
Author
There was a problem hiding this comment.
I realize they're redundant, but it was a bit obscure identifying the mismatch with the bytes, so I thought this more specific assertion might be more diagnostic of failures
radarhere
approved these changes
Apr 3, 2025
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.
This implements a fix for the issue identified in AOMediaCodec/libavif#2727 and fixed in AOMediaCodec/libavif#2729. The code in Pillow that converts irot and imir properties to EXIF orientation was repurposed from libavif, so it suffers the same bug.