How do I parse the offset to the second ifd table (tiff files)

73 views Asked by At

For a project I am writing an parser which is just supposed to extract one single exif tag from an image file (for efficiency reasons, in the end its supposed to parse the DateTimeOriginal Tag out of ~3.5 mil images) I have already figured out how to parse the tiff header and the tags form the first ifd table. But now I am stuck at the point where I need to get the offset to the next ifd table. I looked around the internet and found the tags SubIFD and InteroperabilityOffset, but all I could find is conflicting information. The official documentation from Adobe reads:

"An Image File Directory (IFD) consists of a 2-byte count of the number of directory entries (i.e., the number of fields), followed by a sequence of 12-byte field entries, followed by a 4-byte offset of the next IFD (or 0 if none). (Do not forget to write the 4 bytes of 0 after the last IFD.)"

But when looking at some of my own images using a hext editor I couldnt find that offset, the four bytes after the first ifd table only ever pointed to some bogus adress in the middle of the image data or to an adress that doesnt even exist because the file is not that big. Now my question: Is there anything I overlooked here? Maybe I missed some detail about how the offsets work or where they are acctually stored?

P.S: I did consider byte order so that is not where the issue lies

0

There are 0 answers