-
Notifications
You must be signed in to change notification settings - Fork 254
Fixes wrong EXIF Orientation from Irot Imir #2729
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,8 @@ | |
|
|
||
| #include "avif/avif.h" | ||
| #include "avif/avif_cxx.h" | ||
| #include "avif/internal.h" | ||
| #include "avifexif.h" | ||
| #include "avifjpeg.h" | ||
| #include "avifpng.h" | ||
| #include "aviftest_helpers.h" | ||
|
|
@@ -284,6 +286,22 @@ TEST(MetadataTest, ExifOrientation) { | |
| EXPECT_EQ(image->width, temp_image->width /* should be height here */); | ||
| } | ||
|
|
||
| TEST(MetadataTest, AllExifOrientations) { | ||
| const ImagePtr image = | ||
| testutil::ReadImage(data_path, "paris_exif_orientation_5.jpg"); | ||
| ASSERT_NE(image, nullptr); | ||
| image->transformFlags = AVIF_TRANSFORM_NONE; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: It seems better to move these four lines (290-293) into the for loop so that each iteration of the for loop starts from a clean image. Right now each iteration starts from the results of the previous iteration.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in #2735 |
||
| for (uint8_t orientation = 1; orientation <= 8; ++orientation) { | ||
| // Check roundtrip. | ||
| ASSERT_EQ(avifSetExifOrientation(&image->exif, orientation), | ||
| AVIF_RESULT_OK); | ||
| ASSERT_EQ(avifImageExtractExifOrientationToIrotImir(image.get()), | ||
| AVIF_RESULT_OK); | ||
| ASSERT_EQ(avifImageGetExifOrientationFromIrotImir(image.get()), | ||
| orientation); | ||
| } | ||
| } | ||
|
|
||
| TEST(MetadataTest, ExifOrientationAndForcedImir) { | ||
| const ImagePtr image = | ||
| testutil::ReadImage(data_path, "paris_exif_orientation_5.jpg"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified the bug fix by comparing this function with the corresponding code in Chrome. You can skip the following details.
Details:
In Chrome (third_party/blink/renderer/platform/image-decoders/avif/crabbyavif_image_decoder.cc), this operation is implemented as a table lookup (I replaced the symbolic constants with numeric values in the lookup table):
To match the code here, we need to read each column in Chrome's lookup table from the bottom up. For example, the second column read from the bottom up is 7, 5, 8. This should match the first outermost if block in this function. This confirms the last entry should be 8, not 6.
Similarly, the third column read from the bottom up is 4, 2, 3. This matches the second outermost if block in this function.
The fourth column read from the bottom up is 5, 7, 6. This matches the new code in the third outermost if block in this function.
Finally, the first column read from the bottom up is 2, 4, 1. This matches the last outermost if block and the final return statement in this function.