Closed japheth-sh closed 1 year ago
It is an Apple "feature". See https://github.com/strukturag/libheif/issues/227
Oh...glad to have a light speed response. I will have a look.
well...If I read #227 correctly, it is related to the battle of exif:orientation and irot, not my case. My 43.heic has no irot, only exif:orientation. If I remove the compatible brand "miaf" manually, the exif:orientation can be recognized correctly by Mac. I believe Mac use the policy "use either irot or exif:orientation, but not both" to handle #227 issue.
See: then:
Is it possible that the photo must be "grided" when "miaf" appears in compatible brands? I see the original photo does.
MIAF only puts some further restrictions on HEIF. It does not change the interpretation. Hence, if the orientation that macOS displays depends on the MIAF compatibility, it looks like a macOS bug to me.
There was a lot of confusion about the fact that unlike JPEG, the EXIF rotation value has no effect for HEIF and many implementations did it wrong. Thus, maybe macOS uses the MIAF in some heuristics on how they interpret the EXIF data instead of strictly following the standard.
I can say more: when a file contains multiple images, the Apple Preview app (on macOS Monterey) doesn't account Exif orientation (tested this June). Exactly the opposite as with one.
Mine contains only one still image. Maybe "miaf" misguided MacOS? Is it possible we have an official patch with no "miaf" when there is only one image?
I don't think it's a good idea to introduce "bugs" into libheif just to compensate bugs in some other software. There may be a set of programs that only accept MIAF images because of their stricter specification.
Ok...so my 43.heic is a correct heic file and we can ignore Mac incorrect orientation, right?
You can attach the two images (43.heic and the original) to here and I'll check whether the file is correct. If it is, it's on Apple to fix their bug.
heics.zip @farindk Here you are. Thanks a lot for checking this.
I had a closer look at 43.heif
.
There is one unexpected thing in this file: the EXIF Orientation is set to "90 CW", but there is no 'irot' box in the HEIC. The image itself is stored in the rotated orientation. I.e. the HEIC file is stored with a wrong orientation.
The EXIF Orientation should probably have been removed somewhere during the conversion and the image rotated.
The combination of a rotation in EXIF Orientation and no irot
box is also unexpected by heif_convert
, leading to a wrong conversion to JPEG, but which in this case just cancels out the error in the HEIC file. However, this should be corrected (#680).
Concerning the Apple output:
The landscape display of 43.heic
is correct.
I.e. my guess is that when 'miaf' is present, Apple uses the strict standard compliant decoding which (correctly) ignores the EXIF data, while without 'miaf' it switches to a "compatibility" mode that uses the EXIF Orientation because a lot of software got it wrong at the beginning and new software does basically always include 'miaf'.
I am use ImageMagick which is using libheif to handle heic files. However, when I convert photos to heic, their exif orientations are always recognized as 1 (no rotate) while Exif orientation is not 1. Here's the example: 43.txt See blow 43.heic is not placed correctly. (43ae...ff27.heic is the original photo, I used "convert -define heic:preserve-orientation=true 43ae6f68-7f55-4228-bff3-61c2b383ff27.heic 43.heic")
And Preview App says orientation is 1:
Looks like the m_miaf_compatible is set to true by default and only set to false in some cases. Thus most of heic files will have the "miaf" appended. Is this a bug or Apple's fault?