2012.11.24 00:09 "[Tiff] help writing thumbnails to TIFF file?", by Paul Heckbert

2012.11.27 02:10 "Re: [Tiff] help writing thumbnails to TIFF file?", by Paul Heckbert

We have several opinions so far:

Daniel McCoy said he implemented TIFFCheckpointDirectory years ago to allow partially-written TIFF files to be read. Olivier Paquet and Edward Lam said that they use this function for that purpose, and it works for them. Edward thinks that most other people should not use TIFFCheckpointDirectory.

Joris Van Damme referred to the function as a hack that served a mysterious function for its original developers. He added that it would be unlikely to suit me or anyone else but he didn't explain why it wouldn't, other than to compare TIFFCheckpointDirectory to Stonehenge. He argued that people shouldn't care about the order of data in their TIFF files.

I side with those that are saying that TIFFCheckpointDirectory is useful and (at least sometimes) works properly. Without TIFFCheckpointDirectory, the directory would always appear at the end of a TIFF file, after the pixels, and reading partial TIFF files would be impossible. Some control of data order in the file IS useful, namely: does the directory appear before or after the pixels?

Other situations where it's useful to have the directory first: if a file is being streamed in, you might want to inspect the directory and cancel the streaming. And for very large files (I currently work with TIFFs up to 4 gigabytes, and soon, larger) it's nice to maximize performance and minimize seek times by putting directories, thumbnails, and other header-like information at the beginning of a file. That's also the order in which most of the rest of the world writes their TIFF files.

PS: If we're interested in distant history, I worked with Sam Leffler at Pixar in 1986 and he and I wrote the Pixar Software Standards document together.

Returning to my code:

I wonder if others have attempted to write two directories (IFDs) using TIFFCheckpointDirectory. Anyone got pointers to code that does this? Am I using TIFFSetDirectory properly?

My current hypothesis: TIFFCheckpointDirectory works fine if you're writing only one directory, but it's buggy when there are multiple directories.

I tested further and it seems that my program, when run with "thumb - nocheckpoint", yields a TIFF that "exiftool -hexdump" can parse properly even though the directories follow the pixels. I don't know if other TIFF-reading software can parse it properly, however.