Home | man(3)
TIFFGETFIELD(3tiff) LibTIFF TIFFGETFIELD(3tiff)
NAME
TIFFGetField - get the value(s) of a tag in an open TIFF file
SYNOPSIS
#include <tiffio.h>
#include <stdarg.h>
int TIFFGetField(TIFF *tif, ttag_t tag, ...)
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)
DESCRIPTION
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 li‐
brary but whose value is not read or written to the underlying file.)
The file must have been previously opened with TIFFOpen(). 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.h interface. The re‐
turned 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(), respectively, 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 the number of parameter values, and the
types for the returned values are shown below. The data types are spec‐
ified as in C and correspond to the types used to specify tag values to
TIFFSetField(). 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 indus‐
try specification) for information on the meaning of each tag and their
possible values.
TAG PROPERTIES
box center; l|l|l|l. T{ Tag name T} T{ Count T} T{ Types T} T{
Notes T} _ T{ TIFFTAG_ARTIST T} T{ 1 T} T{ const char** T} T{ T}
_ T{ TIFFTAG_BADFAXLINES T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{
TIFFTAG_BITSPERSAMPLE T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFF‐
TAG_CLEANFAXDATA T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFF‐
TAG_COLORMAP T} T{ 3 T} T{ const uint16_t** T} T{ 1 << BitsPer‐
Sample arrays T} _ T{ TIFFTAG_COMPRESSION T} T{ 1 T} T{ uint16_t*
T} T{ T} _ T{ TIFFTAG_CONSECUTIVEBADFAXLINES T} T{ 1 T} T{
uint32_t* T} T{ T} _ T{ TIFFTAG_COPYRIGHT T} T{ 1 T} T{ const
char** T} T{ T} _ T{ TIFFTAG_DATATYPE T} T{ 1 T} T{ uint16_t*
T} T{ T} _ T{ TIFFTAG_DATETIME T} T{ 1 T} T{ const char** T} T{
T} _ T{ TIFFTAG_DOCUMENTNAME T} T{ 1 T} T{ const char** T} T{ T}
_ T{ TIFFTAG_DOTRANGE T} T{ 2 T} T{ uint16_t* T} T{ T} _ T{ TIFF‐
TAG_EXTRASAMPLES T} T{ 2 T} T{ uint16_t*, const uint16_t** T} T{
count, types array T} _ T{ TIFFTAG_FAXFILLFUNC T} T{ 1 T} T{ TIFF‐
FaxFillFunc* T} T{ G3/G4 compression pseudo-tag T} _ T{ TIFFTAG_FAX‐
MODE T} T{ 1 T} T{ int* T} T{ G3/G4 compression pseudo-tag T} _
T{ TIFFTAG_FILLORDER T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFF‐
TAG_GROUP3OPTIONS T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{ TIFF‐
TAG_GROUP4OPTIONS T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{ TIFF‐
TAG_HALFTONEHINTS T} T{ 2 T} T{ uint16_t* T} T{ T} _ T{ TIFF‐
TAG_HOSTCOMPUTER T} T{ 1 T} T{ const char** T} T{ T} _ T{ TIFF‐
TAG_ICCPROFILE T} T{ 2 T} T{ const uint32_t*, const void** T} T{
count, profile dataâ¡ T} _ T{ TIFFTAG_IMAGEDEPTH T} T{ 1 T} T{
uint32_t* T} T{ T} _ T{ TIFFTAG_IMAGEDESCRIPTION T} T{ 1 T} T{
const char** T} T{ T} _ T{ TIFFTAG_IMAGELENGTH T} T{ 1 T} T{
uint32_t* T} T{ T} _ T{ TIFFTAG_IMAGEWIDTH T} T{ 1 T} T{
uint32_t* T} T{ T} _ T{ TIFFTAG_INKNAMES T} T{ 1 T} T{ const
char** T} T{ T} _ T{ TIFFTAG_INKSET T} T{ 1 T} T{ uint16_t*
T} T{ T} _ T{ TIFFTAG_JPEGCOLORMODE T} T{ 1 T} T{ int* T} T{
JPEG pseudo-tag T} _ T{ TIFFTAG_JPEGQUALITY T} T{ 1 T} T{ int*
T} T{ JPEG pseudo-tag T} _ T{ TIFFTAG_JPEGTABLES T} T{ 2 T} T{
uint32_t*, const void** T} T{ count, tables T} _ T{ TIFFTAG_JPEGTA‐
BLESMODE T} T{ 1 T} T{ int* T} T{ JPEG pseudo-tag T} _ T{ TIFF‐
TAG_MAKE T} T{ 1 T} T{ const char** T} T{ T} _ T{ TIFFTAG_MATTE‐
ING T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_MAXSAMPLEVALUE
T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_MINSAMPLEVALUE
T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_MODEL T} T{ 1
T} T{ const char** T} T{ T} _ T{ TIFFTAG_ORIENTATION T} T{ 1
T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_PAGENAME T} T{ 1 T} T{
const char** T} T{ T} _ T{ TIFFTAG_PAGENUMBER T} T{ 2 T} T{
uint16_t* T} T{ T} _ T{ TIFFTAG_PHOTOMETRIC T} T{ 1 T} T{
uint16_t* T} T{ T} _ T{ TIFFTAG_PHOTOSHOP T} T{ 2 T} T{
uint32_t*, const void** T} T{ count, data T} _ T{ TIFFTAG_PLANARCON‐
FIG T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_PREDICTOR
T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_PRIMARYCHROMATICI‐
TIES T} T{ 1 T} T{ const float** T} T{ 6-entry array T} _ T{
TIFFTAG_REFERENCEBLACKWHITE T} T{ 1 T} T{ const float** T} T{
6-entry array T} _ T{ TIFFTAG_RESOLUTIONUNIT T} T{ 1 T} T{
uint16_t* T} T{ T} _ T{ TIFFTAG_RICHTIFFIPTC T} T{ 2 T} T{
uint32_t*, const void** T} T{ count, data T} _ T{ TIFFTAG_ROWSPER‐
STRIP T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{ TIFFTAG_SAMPLEFORMAT
T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_SAMPLESPERPIXEL
T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_SMAXSAMPLEVALUE
T} T{ 1 T} T{ double* T} T{ T} _ T{ TIFFTAG_SMINSAMPLEVALUE
T} T{ 1 T} T{ double* T} T{ T} _ T{ TIFFTAG_SOFTWARE T} T{ 1
T} T{ const char** T} T{ T} _ T{ TIFFTAG_STONITS T} T{ 1 T} T{
double* T} T{ T} _ T{ TIFFTAG_STRIPBYTECOUNTS T} T{ 1 T} T{ const
uint64_t** T} T{ T} _ T{ TIFFTAG_STRIPOFFSETS T} T{ 1 T} T{ const
uint64_t** T} T{ T} _ T{ TIFFTAG_SUBFILETYPE T} T{ 1 T} T{
uint32_t* T} T{ T} _ T{ TIFFTAG_SUBIFD T} T{ 2 T} T{ uint16_t*,
const uint64_t** T} T{ count, offsets array T} _ T{ TIFFTAG_TARGET‐
PRINTER T} T{ 1 T} T{ const char** T} T{ T} _ T{ TIFFTAG_THRESH‐
HOLDING T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_TILEBYTE‐
COUNTS T} T{ 1 T} T{ const uint64_t** T} T{ T} _ T{ TIFF‐
TAG_TILEDEPTH T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{ TIFFTAG_TILE‐
LENGTH T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{ TIFFTAG_TILEOFFSETS
T} T{ 1 T} T{ const uint64_t** T} T{ T} _ T{ TIFFTAG_TILEWIDTH
T} T{ 1 T} T{ uint32_t* T} T{ T} _ T{ TIFFTAG_TRANSFERFUNCTION
T} T{ 1 or 3† T} T{ const uint16_t** T} T{ 1 << BitsPerSample en‐
try arrays T} _ T{ TIFFTAG_WHITEPOINT T} T{ 1 T} T{ const float**
T} T{ 2-entry array T} _ T{ TIFFTAG_XMLPACKET T} T{ 2 T} T{
uint32_t*, const void** T} T{ count, data T} _ T{ TIFFTAG_XPOSITION
T} T{ 1 T} T{ float* T} T{ T} _ T{ TIFFTAG_XRESOLUTION T} T{ 1
T} T{ float* T} T{ T} _ T{ TIFFTAG_YCBCRCOEFFICIENTS T} T{ 1
T} T{ const float** T} T{ 3-entry array T} _ T{ TIFFTAG_YCBCRPOSI‐
TIONING T} T{ 1 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_YCBCRSUB‐
SAMPLING T} T{ 2 T} T{ uint16_t* T} T{ T} _ T{ TIFFTAG_YPOSITION
T} T{ 1 T} T{ float* T} T{ T} _ T{ TIFFTAG_YRESOLUTION T} T{ 1
T} T{ float* T} T{ T}
†: If SamplesPerPixel is one, then a single array is returned; oth‐
erwise three arrays are returned.
â¡: The contents of this field are quite complex. See "The ICC Pro‐
file Format Specification", Annex B.3 "Embedding ICC Profiles in
TIFF Files" (available at http://www.color.org) for an explana‐
tion.
AUTOREGISTERED TAGS
If you can't find the tag in the table above that means this is an un‐
supported tag and is not directly supported by the libtiff library. You
will 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:
uint32_t count;
void *data;
TIFFGetField(tiff, 33424, &count, &data);
printf("Tag %d: %d, count %d\n", 33424, *(uint32_t *)data, count);
TIFFGetField(tiff, 36867, &count, &data);
printf("Tag %d: %s, count %d\n", 36867, (char *)data, count);
RETURN VALUES
1 is returned if the tag is defined in the current directory; otherwise
a 0 is returned.
DIAGNOSTICS
All error messages are directed to the TIFFErrorExtR() routine.
Unknown field, tag 0x%x:
An unknown tag was supplied.
SEE ALSO
TIFFOpen (3tiff), TIFFSetField (3tiff), TIFFSetDirectory (3tiff),
TIFFReadDirectory (3tiff), TIFFWriteDirectory (3tiff), libtiff (3tiff)
AUTHOR
LibTIFF contributors
COPYRIGHT
1988-2022, LibTIFF contributors
4.7 Jul 10, 2026 TIFFGETFIELD(3tiff)