TIFFGETFIELD(3tiff)

🌸 TIFFGETFIELD 🌸

okay bestie, pull up a chair, because this is the TIFFGetField page from the LibTIFF manual (yes, that's the 3tiff section, we're in library-land now πŸ’…). It's a long one so buckle up β€” this is just the beginning, there's more coming.


✨ 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, uint32_t tag, ...)

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

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

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

πŸ’– DESCRIPTION πŸ’–

So like, what does TIFFGetField() actually do? It hands you back the value of a tag β€” or a pseudo-tag β€” that's chilling in the current directory of the TIFF file tif that you've already got open. And no, bestie, a pseudo-tag is not a fake tag, it's just a parameter that controls how the TIFF library behaves, except its value is never read from or written to the actual underlying file. It lives rent free in the library, not on disk. 🌸

The file has to have been opened already with TIFFOpen() first β€” no sneaking in through the window. πŸ”‘

The tag you want is identified by tag, and it's one of the values defined over in the include file tiff.h (peep the table below πŸ‘€). Here's the tea: the type and the number of values you get back completely depends on which tag you asked for. The programming interface uses a variable argument list, exactly as prescribed by the stdarg.h interface. And the big one, the rule that will humble you if you ignore it:

You should ONLY interpret the returned values if TIFFGetField() returns 1. Do not read the outputs otherwise. Fr fr. 😭

TIFFVGetField() is functionally equivalent to TIFFGetField(), the only difference being that it takes a pointer to a variable argument list instead. Why do we care? Because TIFFVGetField() is useful for layering interfaces on top of the functionality that TIFFGetField() already provides. Very demure, very mindful, very wrapper-friendly. 🧚

TIFFGetFieldDefaulted() and TIFFVGetFieldDefaulted() are identical to TIFFGetField() and TIFFVGetField(), respectively β€” except for one iconic little twist: if a tag is not defined in the current directory and it has a default value, then the default value is what gets returned. No tag? No problem, here's the fallback. πŸ‘‘


Now, the tags that libtiff understands, the number of parameter values, and the types of the returned values are all shown below. The data types are specified as in C, and they correspond to the types used to specify tag values to TIFFSetField(). ⭐

And this is the part people trip over: remember that TIFFGetField() returns parameter values, so every single one of the listed data types is a pointer to storage where values should be returned. You're passing in somewhere for the answer to land, not passing in the answer itself. πŸ™ˆ

For the actual meaning of each tag and what values it can possibly take, go consult the TIFF specification (or whatever relevant industry specification applies) β€” that's not this page's job, bestie. πŸ’œ

✨ TAG PROPERTIES ✨

okay bestie, this is THE table πŸ’… every tag you can pass to TIFFGetField() (and TIFFSetField()), with how many values it wants (Count) and what type of pointer it's gonna hand you (Types). the Notes column is where the tea lives. keep it open in another tab, you'll be coming back here constantly, no cap 🫢

  • TIFFTAG_ARTIST β€” Count 1, Types const char**
  • TIFFTAG_BADFAXLINES β€” Count 1, Types uint32_t*
  • TIFFTAG_BITSPERSAMPLE β€” Count 1, Types uint16_t*
  • TIFFTAG_CLEANFAXDATA β€” Count 1, Types uint16_t*
  • TIFFTAG_COLORMAP β€” Count 3, Types const uint16_t** β€” Notes: 1 << BitsPerSample arrays
  • TIFFTAG_COMPRESSION β€” Count 1, Types uint16_t*
  • TIFFTAG_CONSECUTIVEBADFAXLINES β€” Count 1, Types uint32_t*
  • TIFFTAG_COPYRIGHT β€” Count 1, Types const char**
  • TIFFTAG_DATATYPE β€” Count 1, Types uint16_t*
  • TIFFTAG_DATETIME β€” Count 1, Types const char**
  • TIFFTAG_DOCUMENTNAME β€” Count 1, Types const char**
  • TIFFTAG_DOTRANGE β€” Count 2, Types uint16_t*
  • TIFFTAG_EXTRASAMPLES β€” Count 2, Types uint16_t*, const 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*
  • TIFFTAG_GROUP3OPTIONS β€” Count 1, Types uint32_t*
  • TIFFTAG_GROUP4OPTIONS β€” Count 1, Types uint32_t*
  • TIFFTAG_HALFTONEHINTS β€” Count 2, Types uint16_t*
  • TIFFTAG_HOSTCOMPUTER β€” Count 1, Types const char**
  • TIFFTAG_ICCPROFILE β€” Count 2, Types const uint32_t*, const void** β€” Notes: count, profile data‑
  • TIFFTAG_IMAGEDEPTH β€” Count 1, Types uint32_t*
  • TIFFTAG_IMAGEDESCRIPTION β€” Count 1, Types const char**
  • TIFFTAG_IMAGELENGTH β€” Count 1, Types uint32_t*
  • TIFFTAG_IMAGEWIDTH β€” Count 1, Types uint32_t*
  • TIFFTAG_INKNAMES β€” Count 1, Types const char**
  • TIFFTAG_INKSET β€” Count 1, Types uint16_t*
  • 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*, const void** β€” Notes: count, tables
  • TIFFTAG_JPEGTABLESMODE β€” Count 1, Types int* β€” Notes: JPEG pseudo-tag
lowkey the Count number matters SO much bestie β€” if a tag says 2 and you only pass one pointer, that's not it. and watch out for those pseudo-tags (FAX*, JPEG*) β€” they're giving main character energy but they're not real TIFF tags, iykyk πŸ‘‘

that little ‑ on TIFFTAG_ICCPROFILE? hold that thought, it comes back later πŸŽ€


okay bestie, we're mid-list, so let's just keep the tag parade going β€” M through T, alphabet girlies, let's go πŸŽ€

  • TIFFTAG_MAKE β€” count: 1, type: const char** β€” one string pointer, that's the whole vibe
  • TIFFTAG_MATTEING β€” count: 1, type: uint16_t*
  • TIFFTAG_MAXSAMPLEVALUE β€” count: 1, type: uint16_t*
  • TIFFTAG_MINSAMPLEVALUE β€” count: 1, type: uint16_t*
  • TIFFTAG_MODEL β€” count: 1, type: const char**
  • TIFFTAG_ORIENTATION β€” count: 1, type: uint16_t*
  • TIFFTAG_PAGENAME β€” count: 1, type: const char**
  • TIFFTAG_PAGENUMBER β€” count: 2, type: uint16_t* β€” two of 'em, iconic
  • TIFFTAG_PHOTOMETRIC β€” count: 1, type: uint16_t*
  • TIFFTAG_PHOTOSHOP β€” count: 2, type: uint32_t*, const void** β€” and it also hands you count, data, so it's a whole little duo 🫢
  • TIFFTAG_PLANARCONFIG β€” count: 1, type: uint16_t*
  • TIFFTAG_PREDICTOR β€” count: 1, type: uint16_t*
  • TIFFTAG_PRIMARYCHROMATICITIES β€” count: 1, type: const float** β€” and it's a 6-entry array, periodt
  • TIFFTAG_REFERENCEBLACKWHITE β€” count: 1, type: const float** β€” also a 6-entry array, twins fr πŸ’–
  • TIFFTAG_RESOLUTIONUNIT β€” count: 1, type: uint16_t*
  • TIFFTAG_RICHTIFFIPTC β€” count: 2, type: uint32_t*, const void** β€” same deal, it gives you count, data
  • TIFFTAG_ROWSPERSTRIP β€” count: 1, type: uint32_t*
  • TIFFTAG_SAMPLEFORMAT β€” count: 1, type: uint16_t*
  • TIFFTAG_SAMPLESPERPIXEL β€” count: 1, type: uint16_t*
  • TIFFTAG_SMAXSAMPLEVALUE β€” count: 1, type: double* β€” ooh, double precision, fancy πŸ’…
  • TIFFTAG_SMINSAMPLEVALUE β€” count: 1, type: double*
  • TIFFTAG_SOFTWARE β€” count: 1, type: const char**
  • TIFFTAG_STONITS β€” count: 1, type: double*
  • TIFFTAG_STRIPBYTECOUNTS β€” count: 1, type: const uint64_t**
  • TIFFTAG_STRIPOFFSETS β€” count: 1, type: const uint64_t**
  • TIFFTAG_SUBFILETYPE β€” count: 1, type: uint32_t*
  • TIFFTAG_SUBIFD β€” count: 2, type: uint16_t*, const uint64_t** β€” and it comes with count, offsets array, so you get the count and the whole little offsets situation πŸ”₯
  • TIFFTAG_TARGETPRINTER β€” count: 1, type: const char**
  • TIFFTAG_THRESHHOLDING β€” count: 1, type: uint16_t*
  • TIFFTAG_TILEBYTECOUNTS β€” count: 1, type: const uint64_t**
  • TIFFTAG_TILEDEPTH β€” count: 1, type: uint32_t*
  • TIFFTAG_TILELENGTH β€” count: 1, type: uint32_t*
  • TIFFTAG_TILEOFFSETS β€” count: 1, type: const uint64_t**
  • TIFFTAG_TILEWIDTH β€” count: 1, type: uint32_t*
  • TIFFTAG_TRANSFERFUNCTION β€” count: 1 or 3†, type: const uint16_t** β€” value: 1 <<
okay so that last one is still mid-sentence and that little † dagger is clearly important, bestie β€” we are absolutely not done here, hold that thought πŸ‘€
  • TIFFTAG_WHITEPOINT β€” count 1, type const float**, hands you a 2-entry array πŸ’«
  • TIFFTAG_XMLPACKET β€” count 2, types uint32_t*, const void**, gives you count, data πŸŽ€
  • TIFFTAG_XPOSITION β€” count 1, type float*, no extra note, it's just the vibe πŸ¦‹
  • TIFFTAG_XRESOLUTION β€” count 1, type float*, also no note, lowkey simple ✨
  • TIFFTAG_YCBCRCOEFFICIENTS β€” count 1, type const float**, gives you a 3-entry array πŸ”₯
  • TIFFTAG_YCBCRPOSITIONING β€” count 1, type uint16_t* 🌸
  • TIFFTAG_YCBCRSUBSAMPLING β€” count 2, type uint16_t* πŸ’œ
  • TIFFTAG_YPOSITION β€” count 1, type float* ⭐
  • TIFFTAG_YRESOLUTION β€” count 1, type float* πŸ‘‘

† bestie read this one carefully: if SamplesPerPixel is one, then a single array is returned; otherwise three arrays are returned. no cap, that's the whole rule πŸ’…
‑ okay so this one is a lot. The contents of this field are quite complex. Go read "The ICC Profile Format Specification", Annex B.3 "Embedding ICC Profiles in TIFF Files" (available at http://www.color.org) for an explanation. it's giving homework but it's important πŸ™ˆ

✨ AUTOREGISTERED TAGS ✨

So if you're scrolling this whole list like "where is my tag" and you literally cannot find it in the table above? That means it's an unsupported tag and it is not directly supported by the libtiff library. Not a you problem, it's just not on the roster 🫢

But here's the slay: you can still read its value if you know the data type of that tag. Iconic behavior honestly.

For example, if you want to read the LONG value from the tag 33424 and the 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);

like?? that's the whole trick and it works. periodt πŸ’–


🌈 RETURN VALUES 🌈

1 is returned if the tag is defined in the current directory; otherwise a 0 is returned.

That's it. One or zero. Binary queen. ⭐


πŸ’€ DIAGNOSTICS πŸ’€

All error messages are directed to the TIFFErrorExtR() routine.

  • Unknown field, tag 0x%x: β€” An unknown tag was supplied. yeah, you passed it something it does not recognize 😭

πŸ¦‹ SEE ALSO πŸ¦‹

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

go read those next, they're all connected, iykyk ✨


πŸ‘‘ AUTHOR πŸ‘‘

LibTIFF contributors

1988-2025, LibTIFF contributors


okay that's a wrap bestie!! this was libtiff version 4.7, dated Jun 27, 2026, and the page is TIFFGETFIELD(3tiff) πŸŽ€ you made it to the end, so proud of you, go read a tag fr fr πŸ’–βœ¨πŸ¦‹