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 ifTIFFGetField()returns1. 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β Count1, Typesconst char**TIFFTAG_BADFAXLINESβ Count1, Typesuint32_t*TIFFTAG_BITSPERSAMPLEβ Count1, Typesuint16_t*TIFFTAG_CLEANFAXDATAβ Count1, Typesuint16_t*TIFFTAG_COLORMAPβ Count3, Typesconst uint16_t**β Notes:1 << BitsPerSamplearraysTIFFTAG_COMPRESSIONβ Count1, Typesuint16_t*TIFFTAG_CONSECUTIVEBADFAXLINESβ Count1, Typesuint32_t*TIFFTAG_COPYRIGHTβ Count1, Typesconst char**TIFFTAG_DATATYPEβ Count1, Typesuint16_t*TIFFTAG_DATETIMEβ Count1, Typesconst char**TIFFTAG_DOCUMENTNAMEβ Count1, Typesconst char**TIFFTAG_DOTRANGEβ Count2, Typesuint16_t*TIFFTAG_EXTRASAMPLESβ Count2, Typesuint16_t*,const uint16_t**β Notes: count, types arrayTIFFTAG_FAXFILLFUNCβ Count1, TypesTIFFFaxFillFunc*β Notes: G3/G4 compression pseudo-tagTIFFTAG_FAXMODEβ Count1, Typesint*β Notes: G3/G4 compression pseudo-tagTIFFTAG_FILLORDERβ Count1, Typesuint16_t*TIFFTAG_GROUP3OPTIONSβ Count1, Typesuint32_t*TIFFTAG_GROUP4OPTIONSβ Count1, Typesuint32_t*TIFFTAG_HALFTONEHINTSβ Count2, Typesuint16_t*TIFFTAG_HOSTCOMPUTERβ Count1, Typesconst char**TIFFTAG_ICCPROFILEβ Count2, Typesconst uint32_t*,const void**β Notes: count, profile dataβ‘TIFFTAG_IMAGEDEPTHβ Count1, Typesuint32_t*TIFFTAG_IMAGEDESCRIPTIONβ Count1, Typesconst char**TIFFTAG_IMAGELENGTHβ Count1, Typesuint32_t*TIFFTAG_IMAGEWIDTHβ Count1, Typesuint32_t*TIFFTAG_INKNAMESβ Count1, Typesconst char**TIFFTAG_INKSETβ Count1, Typesuint16_t*TIFFTAG_JPEGCOLORMODEβ Count1, Typesint*β Notes: JPEG pseudo-tagTIFFTAG_JPEGQUALITYβ Count1, Typesint*β Notes: JPEG pseudo-tagTIFFTAG_JPEGTABLESβ Count2, Typesuint32_t*,const void**β Notes: count, tablesTIFFTAG_JPEGTABLESMODEβ Count1, Typesint*β Notes: JPEG pseudo-tag
lowkey the Count number matters SO much bestie β if a tag says2and 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 vibeTIFFTAG_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, iconicTIFFTAG_PHOTOMETRICβ count:1, type:uint16_t*TIFFTAG_PHOTOSHOPβ count:2, type:uint32_t*, const void**β and it also hands youcount, 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 a6-entry array, periodtTIFFTAG_REFERENCEBLACKWHITEβ count:1, type:const float**β also a6-entry array, twins fr πTIFFTAG_RESOLUTIONUNITβ count:1, type:uint16_t*TIFFTAG_RICHTIFFIPTCβ count:2, type:uint32_t*, const void**β same deal, it gives youcount, dataTIFFTAG_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 withcount, 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β count1, typeconst float**, hands you a2-entry arrayπ«TIFFTAG_XMLPACKETβ count2, typesuint32_t*, const void**, gives youcount, dataπTIFFTAG_XPOSITIONβ count1, typefloat*, no extra note, it's just the vibe π¦TIFFTAG_XRESOLUTIONβ count1, typefloat*, also no note, lowkey simple β¨TIFFTAG_YCBCRCOEFFICIENTSβ count1, typeconst float**, gives you a3-entry arrayπ₯TIFFTAG_YCBCRPOSITIONINGβ count1, typeuint16_t*πΈTIFFTAG_YCBCRSUBSAMPLINGβ count2, typeuint16_t*πTIFFTAG_YPOSITIONβ count1, typefloat*βTIFFTAG_YRESOLUTIONβ count1, typefloat*π
β 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
π COPYRIGHT π
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 πβ¨π¦
π¦ where this page comes from
- fedora 43: libtiff-devel 4.7.2-1.fc43
- fedora 43: libtiff-devel 4.7.2-1.fc43
- fedora 43: libtiff-devel 4.7.2-3.fc43 Β· libtiff
- fedora 43: libtiff-devel 4.7.2-3.fc43 Β· libtiff
- fedora 44: libtiff-devel 4.7.2-1.fc44
- fedora 44: libtiff-devel 4.7.2-1.fc44
- fedora 44: libtiff-devel 4.7.2-3.fc44 Β· libtiff
- fedora 44: libtiff-devel 4.7.2-3.fc44 Β· libtiff
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms