2012.11.28 03:06 "Re: [Tiff] help writing thumbnails to TIFF file?", by Olivier Paquet
On Tue, Nov 27, 2012 at 9:38 AM, Olivier Paquet <email@example.com> wrote:
My current hypothesis: TIFFCheckpointDirectory works fine if you're writing only one directory, but it's buggy when there are multiple directories.
Quite possible. It works by keeping the directory in memory for further checkpoints or the final write. Getting it to work with multiple directories requires rereading them (with TIFFSetDirectory) which is very different. It does look like it should work so it can't be that far from actually working. I will try to find some time to take a closer look.
After trying a few ugly hacks in libtiff, I got an apparently valid file with both libtiff 3 and 4 by adding a TIFFWriteDirectory call after each of your TIFFCheckpointDirectory calls. The file looks good in tiffinfo and tiffdump, will split with tiffsplit and opens in KDE's viewer (okular) as two pages of different resolution. tiffdump shows the layout to be IFD0, IFD1, data for IFD1, data for IFD0. I don't know how future-proof this is but it at least appears to work for now, in this specific case. Oh and it even passes valgrind :)