2007.01.31 10:53 "[Tiff] Interpreting SubIFDs tag", by mikk

2007.01.31 17:23 "Re: [Tiff] Interpreting SubIFDs tag", by Joris Van Damme

mikk,

I'm a bit confused with interpreting SubIFDs tag value.

Each value of N values in SubIFDs tag is an offset (from the beginning of the TIFF file, as always) to a child IFD. But is each value of N values an offset to a single child IFD, or to the first IFD from a linked list of IFDs? When I read each of these N child IFDs, am I supposed to interpret NextIFDOffset field and read next directory from this position for each of child IFDs?

Both are possible, and both are common. In fact, sometimes both are combined, and I've come accross files where the same second and third SubIFD gets pointed to in both ways.

What I do, is take the value of the SubIFDs tag as an array, and build a list of pending IFDs to read from that. For each IFD I read, I take its next IFD offset pointer and if it's not zero marking the end of the list, I add it to the front of that list of pending IFDs to read. Before adding any initial or secondary value to the list, I double-check and see that I've not read that IFD before.

The first part of this scheme makes sure I get at all SubIFDs, whether they are mentioned inside the tag value or inside a linked list, or both. The last action prevents double inclusion and IFD looping.

Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html