1994.12.02 20:30 "Appending images to an existing file", by Venkatesh Narayanan
I'm trying to append some images to an existing TIFF file that already has an image in it. I'm not having much sucess doing this. Here is the sequence of calls I'm making:
tiff = TIFFFOpen(filename, "r+"); //I've also tried "a" without success
TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, xsize);
TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, ysize);
TIFFSetField(tiff, TIFFTAG_IMAGEDEPTH, 1);
TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, bpp);
TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, ttype);
TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, csize);
TIFFSetField(tiff, TIFFTAG_TILEWIDTH, xPageSize);
TIFFSetField(tiff, TIFFTAG_TILELENGTH, yPageSize);
TIFFSetField(tiff, TIFFTAG_TILEDEPTH, 1);
TIFFSetDirectory(tiff, 1); //this always fails and I get the message :
//"Could not index into TIFF directory"
While(..there are tiles to write..)
TIFFWriteEncodedTile (tiff, tile, bufdata, bytecount);
Even if I take out the TIFFSetDirectory() call, what happens is that the existing file has been corrupted and can't be read at all. Anyone successfully appended images? The README file says that the append mode hasn't been tested.
Any help is welcome.
Venkatesh Narayanan Silicon Graphics, Inc.
AGD/Image Processing (415) 390-5314 firstname.lastname@example.org