TIFFSETFIELD(3tiff)

🌸 NAME 🌸

TIFFSetField β€” set the value(s) of a tag in a TIFF file open for writing πŸ’…

so yeah bestie, this is TIFFSETFIELD(3tiff) from the LibTIFF manual, and it's literally the "how do I put a value on a tag" page. iconic behavior.


✨ SYNOPSIS ✨

#include <tiffio.h>
#include <stdarg.h>"

int TIFFSetField(TIFF *tif, uint32_t tag, ...)

int TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)

int TIFFUnsetField(TIFF *tif, uint32_t tag)

(and yes, that stray " after stdarg.h is really in there, we don't make the rules πŸ™ˆ)


πŸ’œ DESCRIPTION πŸ’œ

okay so TIFFSetField() sets the value of a field or a pseudo-tag in the current directory associated with the open TIFF file tif. quick vibe check on pseudo-tags: a pseudo-tag is a parameter that controls how the TIFF library operates, but its value is not read from or written to the underlying file. so it's like, a mood, not a record. πŸ’­

to set the value of a field, the file has to have already been opened for writing with TIFFOpen(). that's the whole deal β€” no write-open, no setting fields. pseudo-tags though? those you can set whether the file was opened for reading or writing. flexible queens. πŸ‘‘

the field itself is identified by tag, which is one of the values defined in the include file tiff.h (there's also a table further down, keep scrolling). the actual value gets specified with a variable argument list, exactly as the stdarg.h interface prescribes. very ... of it. ✨

TIFFVSetField() is functionally equivalent to TIFFSetField() β€” same energy, same results β€” except it takes a pointer to a variable argument list. it's the one you want when you're writing routines layered on top of the functionality that TIFFSetField() gives you. 🫢

TIFFUnsetField() clears the contents of the field in the internal structure. and if it's a custom field? it gets removed from the list of known tags. gone. deleted. no cap. πŸ’€

the tags libtiff understands, how many parameter values each one takes, and the expected types for those parameter values, are all shown below. the data types go like this:


πŸŽ€ TAG DATA TYPES πŸŽ€

  • char* β€” a null-terminated string corresponding to the ASCII data type 🌸
  • uint16_t β€” an unsigned 16-bit value
  • uint32_t β€” an unsigned 32-bit value;
  • uint16_t* β€” an array of unsigned 16-bit values. (yes, an array, plural energy πŸ¦‹)
  • void* β€” an array of data values of unspecified type. mysterious. main character. ✨
πŸ“– consult the TIFF specification for information on the meaning of each tag. like, fr fr β€” this page tells you how to set them, the spec tells you what they actually mean.

okay that's the setup out of the way, and the big tag table is coming right up next, so don't go anywhere bestie πŸ’–


🏷️ TAG PROPERTIES 🏷️

ok so this is the big one bestie. every tag you can hand to TIFFSetField lives in this table, and each row tells you three things: the tag's name, its Count (how many values it wants), and the Types it accepts. there's also a little Notes column for the ✨extra lore✨ β€” like when a tag is a pseudo-tag, or when the value count is something you have to compute yourself.

some of these rows have a little dagger (†) sitting in the Notes column, exactly like in the original table. it's there, it's mysterious, it's giving cryptic. πŸ™ˆ

  • TIFFTAG_ARTIST β€” Count 1, Types char*
  • TIFFTAG_BADFAXLINES β€” Count 1, Types uint32_t
  • TIFFTAG_BITSPERSAMPLE β€” Count 1, Types uint16_t, Notes †
  • TIFFTAG_CLEANFAXDATA β€” Count 1, Types uint16_t
  • TIFFTAG_COLORMAP β€” Count 3, Types uint16_t*, Notes 1 << BitsPerSample arrays
  • TIFFTAG_COMPRESSION β€” Count 1, Types uint16_t, Notes †
  • TIFFTAG_CONSECUTIVEBADFAXLINES β€” Count 1, Types uint32_t
  • TIFFTAG_COPYRIGHT β€” Count 1, Types char*
  • TIFFTAG_DATETIME β€” Count 1, Types char*
  • TIFFTAG_DOCUMENTNAME β€” Count 1, Types char*
  • TIFFTAG_DOTRANGE β€” Count 2, Types uint16_t
  • TIFFTAG_EXTRASAMPLES β€” Count 2, Types uint16_t, uint16_t*, Notes † count, types array
  • TIFFTAG_FAXFILLFUNC β€” Count 1, Types TIFFFaxFillFunc, Notes G3/G4 compression pseudo-tag
  • TIFFTAG_FAXMODE β€” Count 1, Types int, Notes † G3/G4 compression pseudo-tag
  • TIFFTAG_FILLORDER β€” Count 1, Types uint16_t, Notes †
  • TIFFTAG_GROUP3OPTIONS β€” Count 1, Types uint32_t, Notes †
  • TIFFTAG_GROUP4OPTIONS β€” Count 1, Types uint32_t, Notes †
  • TIFFTAG_HALFTONEHINTS β€” Count 2, Types uint16_t
  • TIFFTAG_HOSTCOMPUTER β€” Count 1, Types char*
  • TIFFTAG_ICCPROFILE β€” Count 2, Types uint32_t, void*, Notes count, profile data*
  • TIFFTAG_IMAGEDEPTH β€” Count 1, Types uint32_t, Notes †
  • TIFFTAG_IMAGEDESCRIPTION β€” Count 1, Types char*
  • TIFFTAG_IMAGELENGTH β€” Count 1, Types uint32_t
  • TIFFTAG_IMAGEWIDTH β€” Count 1, Types uint32_t, Notes †
  • TIFFTAG_INKNAMES β€” Count 2, Types uint16_t, char*
  • TIFFTAG_INKSET β€” Count 1, Types uint16_t, Notes †
  • TIFFTAG_JPEGCOLORMODE β€” Count 1, Types int, Notes † JPEG pseudo-tag
  • TIFFTAG_JPEGQUALITY β€” Count 1, Types int, Notes JPEG pseudo-tag
  • TIFFTAG_JPEGTABLES β€” Count 2, Types uint32_t*, void*, Notes † count, tables
  • TIFFTAG_JPEGTABLESMODE β€” Count 1, Types int, Notes † JPEG pseudo-tag
  • TIFFTAG_MAKE β€” Count 1, Types char*

and bestie… the list does NOT stop there. there's more where that came from, so hold my hand and let's keep scrolling 🫢

  • TIFFTAG_MATTEING β€” count 1, type uint16_t, and yes bestie it's got the † marker on it πŸ’…
  • TIFFTAG_MAXSAMPLEVALUE β€” count 1, a uint16_t, no extra drama
  • TIFFTAG_MINSAMPLEVALUE β€” count 1, uint16_t, also just vibing
  • TIFFTAG_MODEL β€” count 1, type char* (it's a little string, she's a text girlie)
  • TIFFTAG_ORIENTATION β€” count 1, uint16_t, tells the file which way is up
  • TIFFTAG_PAGENAME β€” count 1, char*, name of the page, iconic
  • TIFFTAG_PAGENUMBER β€” count 2, uint16_t β€” two of them, it's giving duo energy
  • TIFFTAG_PHOTOMETRIC β€” count 1, uint16_t
  • TIFFTAG_PHOTOSHOP β€” count ? (mysterious 😭), types uint32_t, void*, notes say count, data
  • TIFFTAG_PLANARCONFIG β€” count 1, uint16_t, † marked, so tread carefully
  • TIFFTAG_PREDICTOR β€” count 1, uint16_t, † on it too
  • TIFFTAG_PRIMARYCHROMATICITIES β€” count 1, float*, and it's a 6-entry array (six!! 🌈)
  • TIFFTAG_REFERENCEBLACKWHITE β€” count 1, float*, † and also a 6-entry array
  • TIFFTAG_RESOLUTIONUNIT β€” count 1, uint16_t, plain and unbothered
  • TIFFTAG_RICHTIFFIPTC β€” count 2, types uint32_t, void*, notes: count, data
  • TIFFTAG_ROWSPERSTRIP β€” count 1, uint32_t, † and it must be > 0 β€” no zero, no negative, do not test her 🚫
  • TIFFTAG_SAMPLEFORMAT β€” count 1, uint16_t, † marker present
  • TIFFTAG_SAMPLESPERPIXEL β€” count 1, uint16_t, † and heads up: the value must be ≀ 4. That's the ceiling, bestie πŸŽ€
  • TIFFTAG_SMAXSAMPLEVALUE β€” count 1, type double
  • TIFFTAG_SMINSAMPLEVALUE β€” count 1, also a double
  • TIFFTAG_SOFTWARE β€” count 1, char* β€” the "what made this file" string
  • TIFFTAG_STONITS β€” count 1, a double, † flagged
  • TIFFTAG_SUBFILETYPE β€” count 1, uint32_t
  • TIFFTAG_SUBIFD β€” count 2, types uint16_t, uint64_t*, notes: count, offsets array
  • TIFFTAG_TARGETPRINTER β€” count 1, char*
  • TIFFTAG_THRESHHOLDING β€” count 1, uint16_t (yes the spelling is THRESHHOLDING, keep it exactly, no correcting her πŸ’–)
  • TIFFTAG_TILEDEPTH β€” count 1, uint32_t, † marker
  • TIFFTAG_TILELENGTH β€” count 1, uint32_t, † and it must be a multiple of 8 β€” that is non-negotiable fr fr
  • TIFFTAG_TILEWIDTH β€” count 1, uint32_t, † and also must be a multiple of 8, same rule, same energy
  • TIFFTAG_TRANSFERFUNCTION β€” count is 1 or 3‑ (yep, one or three, depends), type uint16_t*, and the arrays are 1 << BitsPerSample entries big
  • TIFFTAG_WHITEPOINT β€” count 1, float*, a 2-entry array
  • TIFFTAG_XMLPACKET β€” count 2, types uint32_t, void*, notes: count, data
  • TIFFTAG_XPOSITION β€” count 1, type float
  • TIFFTAG_XRESOLUTION β€” count 1, type float
  • TIFFTAG_YCBCRCOEFFICIENTS β€” count 1, type float*, and it's got a † on it: it's a 3-entry array
  • TIFFTAG_YCBCRPOSITIONING β€” count 1, type uint16_t, †
  • TIFFTAG_YCBCRSAMPLING β€” count 2, type uint16_t, †
  • TIFFTAG_YPOSITION β€” count 1, type float
  • TIFFTAG_YRESOLUTION β€” count 1, type float

πŸ—οΈ the footnote key, iykyk

  • † β€” this tag may not have its values changed once data is written. it's locked in. no takebacks, no edits, periodt πŸ’€
  • ‑ β€” if SamplesPerPixel is one, then a single array is passed; otherwise three arrays should be passed. one array or three, choose wisely bestie πŸŽ€
  • * β€” 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.

✨ RETURN VALUES ✨

1 is returned if the operation was successful. slay πŸ’…

Otherwise, 0 is returned if an error was detected. not slay 😭


🚨 DIAGNOSTICS 🚨

All error messages are directed to the TIFFErrorExtR() routine. every single one. it's giving customer service hotline fr fr πŸ“ž

  • %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. so like, once you've committed, you've committed πŸ™ˆ
  • %d: Bad value for "%s": β€” an invalid value was supplied for the named tag. she said no ❌

πŸ‘€ SEE ALSO πŸ‘€

  • TIFFOpen (3tiff)
  • TIFFGetField (3tiff)
  • TIFFSetDirectory (3tiff)
  • TIFFWriteDirectory (3tiff)
  • TIFFReadDirectory (3tiff)
  • libtiff (3tiff)

πŸ‘‘ AUTHOR πŸ‘‘

LibTIFF contributors β€” the collective, the group chat, the squad 🫢


1988-2025, LibTIFF contributors


okay bestie that's the whole page, we did it, we ate and left no crumbs 🌈✨ this was TIFFSETFIELD(3tiff), version 4.7, dated Jun 27, 2026 β€” go set some fields, you've got this πŸ’…πŸ’œ