TIFFGetField, TIFFVGetField − get the value(s) of a tag in an open TIFF file
#include <tiffio.h>
int TIFFGetField(TIFF *tif, ttag_t tag, ...)
#include <stdarg.h>
int TIFFVGetField(TIFF *tif, ttag_t tag, va_list ap) int TIFFGetFieldDefaulted(TIFF *tif, ttag_t tag, ...) int TIFFVGetFieldDefaulted(TIFF *tif, ttag_t tag, va_list ap)
TIFFGetField returns the value of a tag or pseudo-tag associated with the the current directory of the opened TIFF file tif. (A pseudo-tag is a parameter that is used to control the operation of the TIFF library but whose value is not read or written to the underlying file.) The file must have been previously opened with TIFFOpen(3TIFF). The tag is identified by tag, one of the values defined in the include file tiff.h (see also the table below). The type and number of values returned is dependent on the tag being requested. The programming interface uses a variable argument list as prescribed by the stdarg(3) interface. The returned values should only be interpreted if TIFFGetField returns 1.
TIFFVGetField is functionally equivalent to TIFFGetField except that it takes a pointer to a variable argument list. TIFFVGetField is useful for layering interfaces on top of the functionality provided by TIFFGetField.
TIFFGetFieldDefaulted and TIFFVGetFieldDefaulted are identical to TIFFGetField and TIFFVGetField, except that if a tag is not defined in the current directory and it has a default value, then the default value is returned.
The tags understood by libtiff(3TIFF), the number of parameter values, and the types for the returned values are shown below. The data types are specified as in C and correspond to the types used to specify tag values to TIFFSetField(3TIFF). Remember that TIFFGetField returns parameter values, so all the listed data types are pointers to storage where values should be returned. Consult the TIFF specification (or relevant industry specification) for information on the meaning of each tag and their possible values.
Tag Name
Count
Types
Notes
TIFFTAG_ARTIST
1
char**
TIFFTAG_BADFAXLINES
uint32_t*
TIFFTAG_BITSPERSAMPLE
uint16_t*
TIFFTAG_CLEANFAXDATA
TIFFTAG_COLORMAP
3
uint16_t**
1<<BitsPerSample arrays
TIFFTAG_COMPRESSION
TIFFTAG_CONSECUTIVEBADFAXLINES
TIFFTAG_COPYRIGHT
TIFFTAG_DATATYPE
TIFFTAG_DATETIME
TIFFTAG_DOCUMENTNAME
TIFFTAG_DOTRANGE
2
TIFFTAG_EXTRASAMPLES
uint16_t*,uint16_t**
count & types array
TIFFTAG_FAXFILLFUNC
TIFFFaxFillFunc*
G3/G4 compression pseudo-tag
TIFFTAG_FAXMODE
int*
TIFFTAG_FILLORDER
TIFFTAG_GROUP3OPTIONS
TIFFTAG_GROUP4OPTIONS
TIFFTAG_HALFTONEHINTS
TIFFTAG_HOSTCOMPUTER
TIFFTAG_ICCPROFILE
uint32_t*,void**
count, profile data
TIFFTAG_IMAGEDEPTH
TIFFTAG_IMAGEDESCRIPTION
TIFFTAG_IMAGELENGTH
TIFFTAG_IMAGEWIDTH
TIFFTAG_INKNAMES
TIFFTAG_INKSET
TIFFTAG_JPEGCOLORMODE
JPEG pseudo-tag
TIFFTAG_JPEGQUALITY
TIFFTAG_JPEGTABLES
count & tables
TIFFTAG_JPEGTABLESMODE
TIFFTAG_MAKE
TIFFTAG_MATTEING
TIFFTAG_MAXSAMPLEVALUE
TIFFTAG_MINSAMPLEVALUE
TIFFTAG_MODEL
TIFFTAG_ORIENTATION
TIFFTAG_PAGENAME
TIFFTAG_PAGENUMBER
TIFFTAG_PHOTOMETRIC
TIFFTAG_PHOTOSHOP
count, data
TIFFTAG_PLANARCONFIG
TIFFTAG_PREDICTOR
TIFFTAG_PRIMARYCHROMATICITIES
float**
6-entry array
TIFFTAG_REFERENCEBLACKWHITE
TIFFTAG_RESOLUTIONUNIT
TIFFTAG_RICHTIFFIPTC
TIFFTAG_ROWSPERSTRIP
TIFFTAG_SAMPLEFORMAT
TIFFTAG_SAMPLESPERPIXEL
TIFFTAG_SMAXSAMPLEVALUE
double*
TIFFTAG_SMINSAMPLEVALUE
TIFFTAG_SOFTWARE
TIFFTAG_STONITS
double**
TIFFTAG_STRIPBYTECOUNTS
uint32_t**
TIFFTAG_STRIPOFFSETS
TIFFTAG_SUBFILETYPE
TIFFTAG_SUBIFD
uint16_t*,uint32_t**
count & offsets array
TIFFTAG_TARGETPRINTER
TIFFTAG_THRESHHOLDING
TIFFTAG_TILEBYTECOUNTS
TIFFTAG_TILEDEPTH
TIFFTAG_TILELENGTH
TIFFTAG_TILEOFFSETS
TIFFTAG_TILEWIDTH
TIFFTAG_TRANSFERFUNCTION
1 or 3†
uint16_t**1<<BitsPerSample entry arrays
TIFFTAG_WHITEPOINT
2-entry array
TIFFTAG_XMLPACKET
TIFFTAG_XPOSITION
float*
TIFFTAG_XRESOLUTION
TIFFTAG_YCBCRCOEFFICIENTS
3-entry array
TIFFTAG_YCBCRPOSITIONING
TIFFTAG_YCBCRSUBSAMPLING
TIFFTAG_YPOSITION
TIFFTAG_YRESOLUTION
float*‡
† If SamplesPerPixel is one, then a single array is returned; otherwise three arrays are returned. ‡ The contents of this field are quite complex. See The ICC Profile Format Specification, Annex B.3 "Embedding ICC Profiles in TIFF Files" (available at http://www.color.org) for an explanation.
If you can’t find the tag in the table above that means this is unsupported tag. But you still be able to read it’s value if you know the data type of that tag. For example, if you want to read the LONG value from the tag 33424 and ASCII string from the tag 36867 you can use the following code:
uint16_t count; void *data;
TIFFGetField(tiff, 33424, &count, &data); printf("Tag %d: %d, count %d0, 33424, *(uint32_t *)data, count); TIFFGetField(tiff, 36867, &count, &data); printf("Tag %d: %s, count %d0, 36867, (char *)data, count);
is not supported by libtiff(3TIFF), library
1 is returned if the tag is defined in the current directory; otherwise a 0 is returned.
All error messages are directed to the TIFFError(3TIFF) routine.
Unknown field, tag 0x%x. An unknown tag was supplied.
TIFFOpen(3TIFF), TIFFSetField(3TIFF), TIFFSetDirectory(3TIFF), TIFFReadDirectory(3TIFF), TIFFWriteDirectory(3TIFF) libtiff(3TIFF),
Libtiff library home page: http://www.simplesystems.org/libtiff/