AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.06.07 11:39 "[Tiff] Editing a tiff image using libtiff", by Sachin Garg
2006.06.07 12:51 "Re: [Tiff] Editing a tiff image using libtiff", by Joris
2006.06.12 13:59 "Re: [Tiff] Editing a tiff image using libtiff", by Sachin Garg
2006.06.12 15:09 "Re: [Tiff] Editing a tiff image using libtiff", by Joris
2006.06.13 07:29 "RE: [Tiff] Editing a tiff image using libtiff", by Tillaart, Rob van den
2006.06.13 16:02 "Re: [Tiff] Editing a tiff image using libtiff", by Joris
2006.06.13 08:32 "Re: [Tiff] Editing a tiff image using libtiff", by Gerben Vos
2006.06.13 08:55 "RE: [Tiff] Editing a tiff image using libtiff", by Tillaart, Rob van den
2006.06.13 16:04 "Re: [Tiff] Editing a tiff image using libtiff", by Joris
2006.06.14 09:08 "Re: [Tiff] Editing a tiff image using libtiff", by Gerben Vos

2006.06.14 09:08 "Re: [Tiff] Editing a tiff image using libtiff", by Gerben Vos

If ever a TIFF with memory-management data were to be designed, the data better accompanies each data block.

The easiest way is of course to make a single-linked list: put a pointer to the first free memory block in bytes 8-11. Every free memory block then contains a pointer to the next block in bytes 0-3 of the block, and its own length in bytes 4-7. End of list is indicated by a zero pointer. Blocks of less than 8 bytes can't be linked and are lost. In BigTiff, the pointers and lengths would become 8 bytes, and the minimum reclaimable block size 16 bytes.

Two problems: how to indicate the fact that we have a free block list (a magic number in bytes 12-15?), and non-free-block-list-aware programs that edit a TIFF will destroy it, so implementations using the list should be extremely robust (at the very least, check for pointers outside the file, and that you're not overwriting IFDs). The second problem probably makes this idea too complicated to implement; it may be easier for applications/libraries to just calculate the free spaces from the IFDs.

Sorry, just thinking aloud... :-)

Gerben.