AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1998.06.10 15:00 "TIFFGetField syntax and use", by Steve Garcia
1998.06.10 15:54 "RE: TIFFGetField syntax and use", by Frank Kim
1998.06.10 16:09 "Re: TIFFGetField syntax and use", by Steven Michael Garcia
1998.06.10 16:21 "Re: TIFFGetField syntax and use", by George Sazaklis
1998.06.10 17:04 "RE: TIFFGetField syntax and use", by Bill Davis

1998.06.10 16:21 "Re: TIFFGetField syntax and use", by George Sazaklis

Hi, Steve,

The correct way to use TIFFGetField is to pass pointers to the actual variables as function parameters.

This is because C only supports call by value so when you want to get a result back, you need to use a pointer.

So the right way to do it is:

#include <tiffio.h>

main ()
{
        uint16 photo, bitspersample; /* uint16 is unsigned int with 2 bytes */

        TIFF *tif = TIFFOpen("myfile.tif", "r");
        
        TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo);
        TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
        printf("Photo = %d, Bits/Sample = %d", photo, bitspersample);
        TIFFClose(tif);
}

Also you should check the return value of TIFFGetField for the case where the requested tag does not exist in the TIFF file.

See the manual page for TIFFGetField for a list of tags and the corresponding type.

Good luck!
George Sazaklis