[Geotiff] Reading the Value/Offset of an IFD Entry

Tillerson, Clint CRTILLERSON at mactec.com
Fri Oct 26 10:10:20 EDT 2007


When reading the value/offset attribute for an IFD entry (Tiff tag), I'm
confused about how you to know whether the offset should be read as a
short integer vs. a long integer.  Does that make sense?  In other
words, when the actual value of the tag will not fit into 4 bytes, then
the number represents the offset (in bytes) to where the value or values
are stored.

If I understand correctly (and perhaps I do not), the offset will always
be either a 2-byte or 4-byte integer.  Is that true.   However, I have
no way of knowing whether to read only the first 2 bytes to get the
offset or read all 4 bytes.  The field type attribute tells you the data
type of the tag value, not the data type of offset value.

Here's some background:  I'm writing a Fortran program that extracts
land cover data from GEOTIFF files.  Depending on the source of the
GEOTIFF file, it could be either big endian or little endian thus, I
cannot use a compiler switch to deal with the byte swapping and must
handle byte swapping in my Fortran code when necessary.    The problem
I'm running into is reading the offset value and swapping bytes
appropriately.  If the offset value fits into two bytes, I've discovered
that I must read only the first two bytes and ignore the second two,
else I'm including bytes that aren't part of the offset value.  There
does not seem to be a way to determine whether the offset is stored in
only the first two bytes or all four.

Thanks!
Clint

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/geotiff/attachments/20071026/30c0b696/attachment.html


More information about the Geotiff mailing list