Home | man(3)
TIFFSETFIELD(3tiff) LibTIFF TIFFSETFIELD(3tiff)
NAME
TIFFSetField - set the value(s) of a tag in a TIFF file open for writ‐
ing
SYNOPSIS
#include <tiffio.h>
#include <stdarg.h>"
int TIFFSetField(TIFF *tif, ttag_t tag, ...)
int TIFFVSetField(TIFF *tif, ttag_t tag, va_list ap)
int TIFFUnsetField(TIFF *tif, uint32_t tag)
DESCRIPTION
TIFFSetField() sets the value of a field or pseudo-tag in the current
directory associated with the open 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.) To set the
value of a field the file must have been previously opened for writing
with TIFFOpen(). Pseudo-tags can be set whether the file was opened
for reading or writing. The field is identified by tag, one of the
values defined in the include file tiff.h (see also the table below).
The actual value is specified using a variable argument list, as pre‐
scribed by the stdarg.h interface.
TIFFVSetField() is functionally equivalent to TIFFSetField() except
that it takes a pointer to a variable argument list. TIFFVSetField()
is useful for writing routines that are layered on top of the function‐
ality provided by TIFFSetField().
TIFFUnsetField() clears the contents of the field in the internal
structure. If it is a custom field, it is removed from the list of
known tags.
The tags understood by libtiff, the number of parameter values, and the
expected types for the parameter values are shown below. The data
types are:
TAG DATA TYPES
box center; l|l. T{ Type T} T{ Description T} _ T{ char* T} T{ a
null-terminated string corresponding to the ASCII data type T} _ T{
uint16_t T} T{ an unsigned 16-bit value T} _ T{ uint32_t T} T{ an
unsigned 32-bit value; T} _ T{ uint16_t* T} T{ an array of unsigned
16-bit values. T} _ T{ void* T} T{ an array of data values of un‐
specified type. T}
Consult the TIFF specification for information on the meaning of each
tag.
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{ char* T} T{ T} _ T{
TIFFTAG_BADFAXLINES T} T{ 1 T} T{ uint32_t T} T{ T} _ T{ TIFF‐
TAG_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{ uint16_t* T} T{ 1 << BitsPerSample ar‐
rays 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{ char* T} T{ T} _
T{ TIFFTAG_DATETIME T} T{ 1 T} T{ char* T} T{ T} _ T{ TIFF‐
TAG_DOCUMENTNAME T} T{ 1 T} T{ char* T} T{ T} _ T{ TIFF‐
TAG_DOTRANGE T} T{ 2 T} T{ uint16_t T} T{ T} _ T{ TIFFTAG_EX‐
TRASAMPLES T} T{ 2 T} T{ uint16_t, uint16_t* T} T{ † count, types
array T} _ T{ TIFFTAG_FAXFILLFUNC T} T{ 1 T} T{ TIFFFaxFillFunc
T} T{ G3/G4 compression pseudo-tag T} _ T{ TIFFTAG_FAXMODE T} T{ 1
T} T{ int T} T{ † G3/G4 compression pseudo-tag T} _ T{ TIFFTAG_FIL‐
LORDER T} T{ 1 T} T{ uint16_t T} T{ † T} _ T{ TIFFTAG_GROUP3OP‐
TIONS T} T{ 1 T} T{ uint32_t T} T{ † T} _ T{ TIFFTAG_GROUP4OP‐
TIONS T} T{ 1 T} T{ uint32_t T} T{ † T} _ T{ TIFFTAG_HALFTONE‐
HINTS T} T{ 2 T} T{ uint16_t T} T{ T} _ T{ TIFFTAG_HOSTCOMPUTER
T} T{ 1 T} T{ char* T} T{ T} _ T{ TIFFTAG_ICCPROFILE T} T{ 2
T} T{ uint32_t, void* T} T{ count, profile data* T} _ T{ TIFF‐
TAG_IMAGEDEPTH T} T{ 1 T} T{ uint32_t T} T{ † T} _ T{ TIFFTAG_IM‐
AGEDESCRIPTION T} T{ 1 T} T{ char* T} T{ T} _ T{ TIFFTAG_IMAGE‐
LENGTH 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{ 2
T} T{ uint16_t, 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_JPEGTA‐
BLES T} T{ 2 T} T{ uint32_t*, void* T} T{ † count, tables T} _ T{
TIFFTAG_JPEGTABLESMODE T} T{ 1 T} T{ int T} T{ † JPEG pseudo-tag
T} _ T{ TIFFTAG_MAKE T} T{ 1 T} T{ char* T} T{ T} _ T{ TIFF‐
TAG_MATTEING T} T{ 1 T} T{ uint16_t T} T{ † T} _ T{ TIFF‐
TAG_MAXSAMPLEVALUE T} T{ 1 T} T{ uint16_t T} T{ T} _ T{ TIFF‐
TAG_MINSAMPLEVALUE T} T{ 1 T} T{ uint16_t T} T{ T} _ T{ TIFF‐
TAG_MODEL T} T{ 1 T} T{ 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{ 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{ ? T} T{ uint32_t, void*
T} T{ count, data T} _ T{ TIFFTAG_PLANARCONFIG 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_PRIMARYCHROMATICITIES T} T{ 1 T} T{
float* T} T{ 6-entry array T} _ T{ TIFFTAG_REFERENCEBLACKWHITE
T} T{ 1 T} T{ float* T} T{ † 6-entry array T} _ T{ TIFFTAG_RESO‐
LUTIONUNIT T} T{ 1 T} T{ uint16_t T} T{ T} _ T{ TIFF‐
TAG_RICHTIFFIPTC T} T{ 2 T} T{ uint32_t, void* T} T{ count, data
T} _ T{ TIFFTAG_ROWSPERSTRIP T} T{ 1 T} T{ uint32_t T} T{ † must
be > 0 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{ †
value must be ⤠4 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{ char* T} T{ T} _
T{ TIFFTAG_STONITS T} T{ 1 T} T{ double T} T{ † T} _ T{ TIFF‐
TAG_SUBFILETYPE T} T{ 1 T} T{ uint32_t T} T{ T} _ T{ TIFF‐
TAG_SUBIFD T} T{ 2 T} T{ uint16_t, uint64_t* T} T{ count, offsets
array T} _ T{ TIFFTAG_TARGETPRINTER T} T{ 1 T} T{ char* T} T{ T}
_ T{ TIFFTAG_THRESHHOLDING T} T{ 1 T} T{ uint16_t T} T{ T} _ T{
TIFFTAG_TILEDEPTH T} T{ 1 T} T{ uint32_t T} T{ † T} _ T{ TIFF‐
TAG_TILELENGTH T} T{ 1 T} T{ uint32_t T} T{ † must be a multiple
of 8 T} _ T{ TIFFTAG_TILEWIDTH T} T{ 1 T} T{ uint32_t T} T{ †
must be a multiple of 8 T} _ T{ TIFFTAG_TRANSFERFUNCTION T} T{ 1 or
3â¡ T} T{ uint16_t* T} T{ 1 << BitsPerSample entry arrays T} _ T{
TIFFTAG_WHITEPOINT T} T{ 1 T} T{ float* T} T{ 2-entry array T} _
T{ TIFFTAG_XMLPACKET T} T{ 2 T} T{ uint32_t, 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{ TIFF‐
TAG_YCBCRCOEFFICIENTS T} T{ 1 T} T{ float* T} T{ † 3-entry array
T} _ T{ TIFFTAG_YCBCRPOSITIONING T} T{ 1 T} T{ uint16_t T} T{ †
T} _ T{ TIFFTAG_YCBCRSAMPLING T} T{ 2 T} T{ uint16_t T} T{ † T} _
T{ TIFFTAG_YPOSITION T} T{ 1 T} T{ float T} T{ T} _ T{ TIFF‐
TAG_YRESOLUTION T} T{ 1 T} T{ float T} T{ T}
†: Tag may not have its values changed once data is written.
â¡:
If SamplesPerPixel is one, then a single array is passed; otherwise
three arrays should be passed.
*: 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.
RETURN VALUES
1 is returned if the operation was successful. Otherwise, 0 is re‐
turned if an error was detected.
DIAGNOSTICS
All error messages are directed to the TIFFErrorExtR() routine.
%s: Cannot modify tag "%s" while writing:
Data has already been written to the file, so the specified tag's
value can not be changed. This restriction is applied to all tags
that affect the format of written data.
%d: Bad value for "%s":
An invalid value was supplied for the named tag.
SEE ALSO
TIFFOpen (3tiff), TIFFGetField (3tiff), TIFFSetDirectory (3tiff),
TIFFWriteDirectory (3tiff), TIFFReadDirectory (3tiff), libtiff (3tiff)
AUTHOR
LibTIFF contributors
COPYRIGHT
1988-2022, LibTIFF contributors
4.7 Jul 10, 2026 TIFFSETFIELD(3tiff)