2006.06.07 11:39 "[Tiff] Editing a tiff image using libtiff", by Sachin Garg

2006.06.13 16:02 "Re: [Tiff] Editing a tiff image using libtiff", by Joris Van Damme


If space waste is an issue one could introduce a micro-memory manager (MMM).

Suppopse one wants to update a strip/tile, the traditional scenario is:

  1. the strip is loaded and decompressed in memory.
  2. the strip is edited
  3. the strip is compressed again
  4. the strip is stored at the end of the TIFF file
  5. and tags are updated

An MMM would interact just before step 4.

It looks at the size of the new strip and compares it to the previous size

        If (strip fits) reuse()
        Else append()

On average there is a 50% chance (depends on type of editing) the new strip will fit, so on average the filesize will grow less fast.

That is of course a good idea.

An additional way to handle space is the introduction of an 'alloc-tag'. This tag indicates the size of the 'allocated' block in the file in contrast to the size tag which indicates the count of the bytes used. The MMM described above can make a better decission when to reuse the existing strip space if these 'alloc-tags' would be in the file. Note that if these 'alloc-tags' would be removed TIFF would work just as we know. Drawback of the 'alloc-tags' is of course the space they cost :)

That is an attempt at inserting memory-management data at the wrong level. There's not just compressed image data blocks to manage, but also IFD blocks, tag value blocks (which can be quite large), etc. If ever a TIFF with memory-management data were to be designed, the data better accompanies each data block.

Joris Van Damme
Download your free TIFF tag viewer for windows here: