2011.03.28 18:22 "[Tiff] TIFFReadCustomDirectory and TIFFWriteCustomDirectory", by Steve Underwood

2011.03.29 13:28 "Re: [Tiff] TIFFReadCustomDirectory and TIFFWriteCustomDirectory", by Andreas Kleinert


if you check tif_dirwrite.c you will find the following comment in the custom directory write function:

                 * The file's byte order is opposite to the
                 * native machine architecture.  We overwrite
                 * the directory information with impunity
                 * because it'll be released below after we
                 * write it to the file.  Note that all the
                 * other tag construction routines assume that
                 * we do this byte-swapping; i.e. they only
                 * byte-swap indirect data.

I.e. the directory itself will by endian-converted in-place as treated like kind of temporary buffer prior writing.

I guess - without having checked in detail - that you did/didn't byte-swap some of the directory content prior writing (putting).

BTW, once you figured out how it works, one nice result could be an extra set of functions - as people tend to consider libtiff of being capable of writing e.g. also EXIF data (which is not the case) such easy handling of extra custom directories currently seems to be a weakpoint ;-)


> Hi,

Thanks. That gets me a little bit further. TIFFCurrentDirOffset() does give me the offset of the custom directory. However, the actual directory information being written into IFD block seems to be garbage. So, the next question is how do I control what goes into that custom directory section? TIFFWriteCustomDirectory() seems to scan the current directory info in memory, and output anything which is set and which has the FIELD_CUSTOM tag. However, what I see in the file doesn't seem to make any sense as a TIFF directory.