TIFF and LibTiff Mail List Archive


2000.04.14 06:55 "physical delete - page - multipage tiff", by Gabriel Lupu
2000.04.14 13:18 "Re: physical delete - page - multipage tiff", by Rob Tillaart
2000.04.14 14:25 "Re: physical delete - page - multipage tiff", by Frank Warmerdam
2000.04.15 22:08 "Re: physical delete - page - multipage tiff", by Niles Ritter

2000.04.15 22:08 "Re: physical delete - page - multipage tiff", by Niles Ritter

how can i delete (physical) page(s) from multipage tiff? ( libtiff 3.5.5)

I think you are out of luck. I don't believe there is an advertised way of doing this with libtiff, and even if there was there is no management of unused space in a file with libtiff.

Hope springs eternal....

First, here's a simple (working) alternative:

If you have a multi-page TIFF and you want to create a new TIFF file without a couple of the pages you can use "tiffsplit" to break the orginal image up into separate TIFF images (one per page) and then use "tiffcp" to merge the selected pages back together again. I suspect that any "Page Number" tags will no longer be useful, but I don't know how many software programs use that anyway (they violate the scoping rules for independent tiff-directories as they refer to other directories that may or may not be in the same physical file).

Regarding programmatic In-file deletion:

Even though you can't remove (defragment) the space left, you can still in principle eliminate the page from the logical linked-list of pages by resetting the next-directory offset of the preceding page to the one following. You would need to use the "private" tiff structures in libtiff to do this, the field you need to reset is the tif->tif_nextdiroff; field.

I haven't tried it, but you should be able to walk through the linked list of image-directories until you get to the image just *before* the one you want to 'delete', then walk forward to the one just past the image and get the offset to that directory. Then go back to the preceding image directory, read it, update the tif_nextdiroff, and then try calling TIFFWriteDirectory() (obviously, the image will have to be opened for update).

I have no idea if this will actually work, but it is an interesting science project...