2008.11.18 02:14 "[Tiff] Creating a tiled tiff from scratch (essentially)", by Beck, Tucker A

2008.11.18 02:14 "[Tiff] Creating a tiled tiff from scratch (essentially)", by Beck, Tucker A

I am using libtiff in an image processing application. The input images are tiled, multi-image, JPEG compressed tiff files. I have had great success in opening, converting, and processing the image data using libtiff. Now, I need to be able to store the results of processing in a new tiff file. I have encountered a few problems along the way.

When I create the tiff file, I would like to set up each directory when I create the file. I do not want to store any image data in them at creation, I just want them to be ready for writing data when it needs to be done. There are somewhere between 3 and 7 directories that I need to make. It seems like the only way to do this is to set all the fields for the directory, write a single dummy tile (using TIFFWriteTile) and then write the directory (TIFFWriteDirectory). This seems like an ugly way to do things; I'd rather not have to write any data until absolutely necessary. If I try to write the directory without having written a tile, I get a message that says, "MissingRequired: lib/op.svs: TIFF directory is missing required "TileOffsets" field." Is there any way to set up the directory with all the fields correctly assigned, but no data yet written?

Are there any tutorials/guides/example code out there that show a tiled tif being built from scratch? I would love to see a similar example to what I am trying to do.

Any help is greatly appreciated.

Tucker Beck
Software Developer

Washington State University / Pacific Northwest National Laboratory