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
No Exif data found in HEIF file #2162
Comments
Thanks @novomesk for reporting this issue. I'll take a look when I have some spare time. |
I don't think the parser is sensitive to the order of the iloc/infe boxes. The Exif data is ID=3 which is at offset 306. The Exif metadata is at offset 3432 which is ID=4. I'll investigate more when I am home from vacation. |
The pairs in the The correct offset for Exif is 3260 and XMP is 3566. exiftool -v5 test.heic reports: + [Processing items from ItemInformation directory with 4 entries]
Item 1) 'hvc1' (2663 bytes)
| 0255: 00 00 0a 63 28 01 af 13 0f 9f 35 aa f5 eb d5 ab [...c(.....5.....]
| 0265: 4e 9d 3a 95 2a 54 a7 4e 9d 3a 54 68 d1 a3 4a 8d [N.:.*T.N.:Th..J.]
| 0275: 1a 34 68 d1 80 e6 c8 68 53 ff ff ba e3 a7 94 61 [.4h....hS......a]
...
Item 2) 'grid' (8 bytes)
| [not extracted] (Can't currently extract grid with construction method 1)
Item 3) 'Exif' (306 bytes)
| 0cbc: 00 00 00 00 49 49 2a 00 08 00 00 00 0b 00 00 01 [....II*.........]
| 0ccc: 04 00 01 00 00 00 d1 07 00 00 01 01 04 00 01 00 [................]
...
Item 4) 'application/rdf+xml' (3432 bytes)
... The information exiv2 -pS is:
So, offset 0 requires you to perform a fixup calculation into the
I'll read the BMFF specification to see what is said about this. There is a case that writing offset = 0 in the ILOC array is a bug in GIMP. However, as Exiftool supports this, it's reasonable that Exiv2 should also handle this. I also observe that the Exif data has 4 leading null bytes. I believe Exiv2 deals correctly with this by hunting for the Tiff marker I am confident that a couple of new lines of code will fix this and cause no collateral damage. I'll add your file test.heif (appropriately renamed) to the test suite. |
The test.heic was constructed by libheif. in GIMP I am using libheif's
Unfortunately, I don't know what is right from specification point of view. Dirk @farindk , perhaps you can take a look too, so everyone understand the things in same way? |
According to the HEIF standard (ISO-23008:12, section A.2), the Exif data block starts with a 4-byte offset into the remaining data. I.e. if the data starts immediately with the TIFF header ("MM" or "II"), the offset will be 0. Otherwise, the given number of bytes should be skipped. I don't know why they included this offset in the specification. It's not even clear to me when it would be useful to have extra bytes in front of the header... |
It's amazing what we can get done when we work together. Thank you both for your feedback. I'm confident that Exiv2 "hunts" for the II/MM marker and ignores leading bytes. The offset = 0 in the ILOC array is very convenient for somebody writing a file. The fixup to deal with offset = 0 is an easy little change. I'll do the PR this weekend for branch 0.27-maintenance. |
Great. Note that the case offset != 0 is not just theoretical. I have seen such images. libheif searches for the "II"/"MM" header in the passed Exif data and then places an offset to this in the file. It does not truncate the extra data in front of the header. |
The ISOBMFF specifications are a tough read. For sure, I'm not smart enough to understand the ISO document numbering scheme. For the bmff project, I worked with w15177_15444 and w15177_14496 which states on p88: The item location box (‘iloc’) specifies the actual storage location of each item within the container file as well as the file size of each item. File name, content type (MIME type), etc., of each item are provided by version 1 of the item information box (‘iinf’). Note that it states location ... as well as the file size of each item. For sure, I didn't encounter a file with location == 0 during the bmff project. So, I believe test.heic violates the specification. However, it's easy to add a fixup to calculate the offset into the mdat box and I'm happy to do that. I don't want to get involved in a negotiation with libheif concerning iloc location == 0, however I do believe that should be reviewed and fixed. |
Let me try to clear up the confusion a bit. The offset to the Exif data I was talking about has nothing to do with the ISOBMFF layer (ISO 14496). It is part of the metadata block stored in the iloc. Thus, get the data as specified by the 'iloc' and then, take the first 4 bytes of this data as the offset. |
Thank You, @farindk. I've always been focused on location == 0 in I mentioned the 4 nul bytes and now you've found the specification for that. Thanks for digging into that. I was not worried about that as I believe the Exiv2 code "hunts" for the II/MM marker and ignores leading bytes. When I view the file test.heic on macOS (Catalina 10.15), Preview.app does not show the Exif metadata in the Info panel. I tried unsuccessfully with HexFiend to modify test.heic to replace the When I view test.heic on macOS (Monterey 11.2), it does display Exif metadata, however it's wrong! I will modify exiv2 to do the fixup to handle location == 0 in |
+1 for this problem, I have some HEIC files for which previous exiv2 versions read the EXIF but are now reporting 'data not found'. |
Hi++ @j-m-harris could you provide us few such files for analysis? Thanks. |
Sure @1div0 , thanks for looking at this. This file was generated with IMG_20200731_210636067.heif.gz It was generated in March 2021 when exiv2 didn't read the meta data (reporting 'The file contains data of an unknown image type'). In April 2022 I noted that the current gentoo version of exiv2 did now support the meta data, however the latest version now reports 'No Exif data found in the file'. |
@1div0 On 0.27-maintenance, the relevant |
Any progress on this? I am getting |
@etrigan63 Your issue was already fixed by #2612 but it is not yet released from the 0.28.x branch (it is in 0.27.7 though). The root cause for this one is different. |
Thanks. Any idea as to release date? |
Hello,
I am using
exiv2 0.27.5
and I observed that sometimes it doesn't find metadata in HEIF/HEIC files.For example in the following testfile:
test.zip
However using exiftool, the Exif and XMP metadata is printed:
Please investigate what is the problem with the
test.heic
that the metadata was not found.The text was updated successfully, but these errors were encountered: