
Thread
2001.05.02 19:24 "Re: TIFFSetDirectory speed?", by Joris Van Damme
How costly is it to set the directory in say a 5,000 page TIFF file? For instance, if I want to go to page 4,000 can libtiff easily jump there or does it actually have to read the previous 3,999 pages to get to page 4,000?
I've played with this a while ago too, Michael.
As far as I can see, you are supposed to scan each dir wright up to your page 4,000. LibTiff will scan the whole image directory, every time, and doing this 4,000 times can cost you. If there is something I'm missing here, anyone, please correct me.
There does seem to perhaps be a way around it though. I remember I once wanted to examine the routines for adding/reading thumbnail dirs. Cause these directories are indexed with there position in the file. These routines, I expect, can show us how to work with file positions in this context.
That means there would possibly be two partial solutions:
- In the context of multiple scans through the file (eg in UI browsing situations and the like), one might be able to store the file positions while quickly going through the directories. Afterwards, perhaps it's possible to use these file positions to quickly have LibTiff position itself on the wanted page(s) and continue work there.
- One can perhaps also write a custom tag in the first directory, for example, storing these file positions in the encoding code. That way, the need for initial scanning also becomes elliminated when reading back ones own files.
These are only partial solutions, and they might not work after all or perhaps there are easier ways to accomplish more. I didn't dig into it, really, at the time. But I am still very much interested in any comments on this, too.
Joris