AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

1998.08.10 17:26 "Easiest way to add a tag to a TIFF image", by Rex Jolliff

For quite a while I have been using the TIFF library to add an ImageDescription tag to TIFF images in the following manner (which I now think is wrong):

          if ((PgTiff = TIFFOpen(CurFile, "a")) == 0) {
          DBGError("%s: Could not open %s", D->Accession, CurFile);
          RC = FALSE;
        }
        if (RC && TIFFSetDirectory(PgTiff, 0) != 1) {
          DBGError("%s: could not set tiff dir on %s", D->Accession,
CurFile);
          RC = FALSE;
        }
        if (RC && TIFFSetField(PgTiff, TIFFTAG_IMAGEDESCRIPTION,
            D->Accession) != 1) {
          DBGError("%s: Could not set endorsement in page %s",
D->Accession,
               CurFile);
          RC = FALSE;
        }
        if (RC && TIFFWriteDirectory(PgTiff) != 1) {
          DBGError("%s: Could not write TIFF dir on %s", D->Accession,
CurFile);
          RC = FALSE;
        }
        if (PgTiff != 0)
          TIFFClose(PgTiff);

All of the images stored in the system in question are single directory TIFFs. Currently I'm changing this code to copy the TIFF and add the tag, as is done in tiffcp. However, it seems like alot of effort to copy the image data when I'm not modifiying it in any way. Is there an easier way to do this?

Rex.