LIBTIFF(3tiff)

πŸ’– NAME πŸ’–

libtiff β€” an intro to libtiff, the library for reading and writing TIFF files. This is the manual page LIBTIFF(3tiff), bestie, and it's a long one so buckle up. πŸŽ€


✨ SYNOPSIS ✨

#include <tiffio.h>

cc file.c -ltiff

like. that's it. that's the whole vibe. you include the header, you link the lib, you go off. πŸ’…


🌸 DESCRIPTION 🌸

So libtiff is a library for reading and writing data files encoded with the "Tag Image File" format, Revision 6.0 (or revision 5.0, or revision 4.0 β€” we're not picky, we support all three πŸ’–). This file format is literally made for archiving multi-color and monochromatic image data. iconic behaviour, no cap.

The library supports several compression algorithms, and you pick which one via the Compression field:

  • no compression (1) β€” raw, unfiltered, no thoughts head empty
  • CCITT 1D Huffman compression (2)
  • CCITT Group 3 Facsimile compression (3)
  • CCITT Group 4 Facsimile compression (4)
  • Lempel-Ziv & Welch compression (5)
  • baseline JPEG compression (7)
  • word-aligned 1D Huffman compression (32771)
  • PackBits compression (32773)

and then there's a whole other group of nonstandard compression algorithms that are also supported, because libtiff is generous like that:

  • the 4-bit compression algorithm used by the ThunderScan program (32809) β€” decompression only, so read-only, don't come for me
  • NeXT's 2-bit compression algorithm (32766) β€” also decompression only 😭
  • an experimental LZ-style algorithm known as Deflate (32946)
  • an experimental CIE LogLuv compression scheme designed for images with high dynamic range (32845 for LogL, and 32845 for LogLuv)

okay and now for the byte stuff πŸ¦‹ Directory information may be in either little- or big-endian byte order, and the byte swapping is done automatically by the library β€” you don't have to do a thing, it just handles it, we love a self-sufficient queen. Data bit ordering may be either Most Significant Bit (MSB) to Least Significant Bit (LSB) or LSB to MSB.

and finally, the one limitation bestie, so listen up: the library does not support files in which the BitsPerSample, Compression, MinSampleValue, or MaxSampleValue fields are defined differently on a per-sample basis. (In Rev. 6.0 the Compression tag is not defined on a per-sample basis, so this is immaterial anyway. πŸ™ˆ) so like. don't do that.


🧚 DATA TYPES 🧚

The library makes extensive use of C typedefs to promote portability β€” two whole sets of them, actually: one for communication with clients of the library, and one for internal data structures and parsing of the TIFF format. The following typedefs are exposed to users either through function definitions or through parameters passed through the varargs interfaces. πŸ‘‘

typedef int64_t tmsize_t;   /* signed size type (int32_t on 32-bit platforms) */
typedef void* thandle_t;    /* client data handle */
typedef uint64_t toff_t;    /* file offset */
typedef uint32_t tdir_t;    /* directory index */

πŸ’€ Deprecated typedefs πŸ’€

The following typedefs are deprecated and should be replaced by their defining counterparts. yes bestie, they're old, they're still here, but move on:

typedef uint32_t ttag_t;    /* directory tag */
typedef uint16_t tsample_t; /* sample number */
typedef uint32_t tstrile_t; /* strip or tile number */
typedef tstrile_t tstrip_t; /* strip number */
typedef tstrile_t ttile_t;  /* tile number */
typedef tmsize_t tsize_t;   /* i/o size in bytes */
typedef void *tdata_t;      /* image data ref */

πŸ“Œ the fine print πŸ“Œ

  • Note that tstrip_t, ttile_t, and tsize_t are constrained to be no more than 32-bit quantities by the 32-bit fields they are stored in in the TIFF image. so that's a hard ceiling, not a suggestion.
  • Likewise tsample_t is limited by the 16-bit field used to store the SamplesPerPixel tag.
  • tdir_t constrains the maximum number of IFDs that may appear in an image and may be an arbitrary size (w/o penalty). Starting with libtiff 4.5.0, tdir_t is a 32-bit unsigned integer. Previously, it was a 16-bit unsigned integer. glow-up fr fr. ✨
  • ttag_t must be either int, unsigned int, pointer, or double β€” because the library uses a varargs interface and C restricts the type of the parameter before an ellipsis to be a promoted type.
  • toff_t is defined as uint64_t because TIFF file offsets are (unsigned) 32-bit quantities, and BigTIFF file offsets are unsigned 64-bit quantities. A signed value is used because some interfaces return -1 on error. (yes, -1 my beloved error sentinel πŸ’€)
  • Finally, note that user-specified data references are passed as opaque handles and only cast at the lowest layers where their type is presumed.

🫢 LIST OF ROUTINES 🫢

The following routines are part of the library. Consult specific manual pages for details on their operation; on most systems doing man function-name will work. easy. 😌


bestie we are SO not done β€” this page keeps going, more parts incoming πŸ’– don't go anywhere πŸ¦‹

πŸŽ€ LIBTIFF FUNCTIONS πŸŽ€

okay bestie, this is the big alphabetical roster of functions β€” the whole squad, listed by name, each with a one-liner about what it does. no skipping, no skimming, we're reading all of it together like the icons we are. πŸ’…


  • TIFFAccessTagMethods() β€” hands your app read/write access to the TIFFTagMethods sitting inside the TIFF structure, so you can poke at them without getting your hands on the private TIFF structure itself. peek, don't touch the internals, periodt. 🫢
  • TIFFCheckpointDirectory() β€” writes out the current state of the directory. it's giving "save point but make it TIFF". πŸ’Ύ
  • TIFFCheckTile() β€” checks whether every x,y,z,sample combo is actually within the image. yes queen, verify before you vibe. ✨
  • TIFFCIELabToRGBInit() β€” initializes the CIE L*a*b* 1976 β†’ RGB conversion state. setting the stage, warming up the lights. 🎬
  • TIFFCIELabToXYZ() β€” actually performs the CIE L*a*b* 1976 β†’ CIE XYZ conversion. math but make it fashion. 🌈
  • TIFFCleanup() β€” the auxiliary function that frees the TIFF structure. the cleanup crew, the girls who close the tab, the ones who turn off the lights. 🧹
  • TIFFClientdata() β€” returns the open file's clientdata handle β€” that's the thing representing the file descriptor used inside libtiff. lowkey the ID badge for your file. πŸͺͺ
  • TIFFClientOpen() β€” opens a file for reading or writing. the classic entrance. πŸ‘‘
  • TIFFClientOpenExt() β€” opens a file for reading or writing with options, like re-entrant error and warning handlers getting passed in. same opening energy, extra sparkle. ⭐
  • TIFFClose() β€” closes a TIFF file you previously opened. say bye bestie, we're done here. πŸ‘‹
  • TIFFComputeStrip() β€” returns the strip that contains y,sample. find your strip, know your strip. πŸ¦‹
  • TIFFComputeTile() β€” returns the tile that contains x,y,z,sample. the tile-finding equivalent, equally iconic. 🌸
  • TIFFCreateCustomDirectory() β€” sets things up for a custom directory in an open TIFF file. bespoke. artisanal. you. πŸ’–
  • TIFFCreateDirectory() β€” sets things up for a directory in an open TIFF file. the standard-issue version, still slaying. ✨
  • TIFFCreateEXIFDirectory() β€” sets things up for an EXIF custom directory in an open TIFF file, within a TIFF tag. exif girlies rise. πŸ“Έ
  • TIFFCreateGPSDirectory() β€” sets things up for a GPS custom directory in an open TIFF file, within a TIFF tag. she knows exactly where she is. πŸ“
  • TIFFCurrentDirectory() β€” returns the index of the current directory. where am i? here. the answer is here. 🎯
  • TIFFCurrentDirOffset() β€” returns the file offset of the current directory, instead of an index. different coordinate system, same main character energy. 🧭
  • TIFFCurrentRow() β€” returns the index of the current scanline. row by row, we rise. πŸ“ˆ
  • TIFFCurrentStrip() β€” returns the index of the current strip. πŸŽ€
  • TIFFCurrentTile() β€” returns the index of the current tile. the trio is complete, we love a matching set. πŸ’œ
  • TIFFDataWidth() β€” returns the size of TIFF data types. yes, we're measuring. πŸ“
  • TIFFDefaultStripSize() β€” returns the number of rows for a reasonable-sized strip, based on the current settings of the ImageWidth, BitsPerSample and SamplesPerPixel tags, plus any compression-specific requirements. she reads the room and picks a sensible number, no cap. πŸ”₯

...and the list just keeps going, bestie, we're not even close to done πŸ’…

  • TIFFDefaultTileSize() β€” hands you back the pixel width and height of a reasonable-sized tile; perfect for setting up the TileWidth and TileLength tags ✨
  • TIFFDeferStrileArrayWriting() β€” an advanced writing function that lets you control when and where the [Strip/Tile][Offsets/ByteCounts] arrays get written into the file, and it must be used in one very particular sequence together with TIFFForceStrileArrayWriting() (go read the description, iykyk, do not freestyle this one) πŸ”₯
  • TIFFError() β€” the library-wide error handling function, prints to stderr 🫢
  • TIFFErrorExt() β€” a user-specific library-wide error handling function that can be passed a file handle; inside libtiff that handle gets set to the open TIFF file
  • TIFFErrorExtR() β€” a user-specific re-entrant library error handling function, and you pass it its TIFF structure, which carries the pointer to a user-specific data object ✨
  • TIFFFdOpen() β€” open a file for reading or writing
  • TIFFFdOpenExt() β€” open a file for reading or writing with options, like re-entrant error and warning handlers you can pass in πŸ‘‘
  • TIFFFieldDataType() β€” get the data type from the field information
  • TIFFFieldIsAnonymous() β€” tells you whether the field was unknown to libtiff and got auto-registered πŸ™ˆ
  • TIFFFieldName() β€” get the field name from the field information
  • TIFFFieldPassCount() β€” get whether to pass a value count to Get/SetField
  • TIFFFieldReadCount() β€” get the number of values to be read from the field
  • TIFFFieldSetGetCountSize() β€” returns the size of the count parameter of TIFFSetField() and TIFFGetField()
  • TIFFFieldSetGetSize() β€” returns the data size, in bytes, of the field data type used for libtiff internal storage πŸ’Ύ
  • TIFFFieldTag() β€” get the tag value from the field information
  • TIFFFieldWithName() β€” get the field information given a field name
  • TIFFFieldWithTag() β€” get the field information given a tag
  • TIFFFieldWriteCount() β€” get the number of values to be written to the field
  • TIFFFileName() β€” returns the name of the open file πŸ“
  • TIFFFileno() β€” returns the open file descriptor
  • TIFFFindCODEC() β€” finds the standard codec for that specific scheme πŸŽ€
  • TIFFFindField() β€” get the field information given a tag and a data type
  • TIFFFlush() β€” flush all pending writes 🌊
  • TIFFFlushData() β€” flush pending data writes
  • TIFFForceStrileArrayWriting() β€” an advanced writing function
  • TIFFFreeDirectory() β€” frees up the storage that was hanging out with a directory πŸ’… like, bye storage, we're done here
  • TIFFGetBitRevTable() β€” hands you back the bit reversal table ✨
  • TIFFGetClientInfo() β€” gives you a pointer to the data of the entry with that name in the clientinfo-list, iykyk πŸŽ€
  • TIFFGetCloseProc() β€” returns a pointer to the file close method 🫢
  • TIFFGetConfiguredCODECs() β€” gets the list of configured codecs β€” both the built-in ones and the ones a user registered, no cap πŸ”₯
  • TIFFGetField() β€” returns the tag value in the current directory πŸ‘‘
  • TIFFGetFieldDefaulted() β€” same vibe, returns the tag value in the current directory, but with the default value set if the value isn't already set and a default is defined 🌸
  • TIFFGetMaxCompressionRatio() β€” returns the maximum compression ratio for the current codec πŸ’€ (it's giving "how small can we make this")
  • TIFFGetMapFileProc() β€” returns a pointer to the memory mapping method πŸ¦‹
  • TIFFGetMode() β€” returns the open file mode ⭐
  • TIFFGetReadProc() β€” returns a pointer to the file read method πŸ’–
  • TIFFGetSeekProc() β€” returns a pointer to the file seek method ✨
  • TIFFGetSizeProc() β€” returns a pointer to the file size requesting method 🌈
  • TIFFGetStrileByteCount() β€” returns the value of the TileByteCounts/StripByteCounts array for the specified tile/strile 🧚
  • TIFFGetStrileByteCountWithErr() β€” literally the same as TIFFGetStrileByteCount() but it also provides an error return, so you're not left guessing 😭
  • TIFFGetStrileOffset() β€” returns the value of the TileOffsets/StripOffsets array for the specified tile/strile πŸ’…
  • TIFFGetStrileOffsetWithErr() β€” same as TIFFGetStrileOffset() and additionally provides an error return, bestie πŸ™ˆ
  • TIFFGetTagListCount() β€” returns the number of entries in the custom tag list πŸ“
  • TIFFGetTagListEntry() β€” returns the tag number of the (n.th - 1) entry within the custom tag list πŸ‘‘
  • TIFFGetUnmapFileProc() β€” returns a pointer to the memory unmapping method πŸŽ€
  • TIFFGetVersion() β€” returns the library version string ⭐
  • TIFFGetWriteProc() β€” returns a pointer to the file write method πŸ’œ
  • TIFFIsBigEndian() β€” returns a non-zero value if the file is BigEndian and zero if the file is LittleEndian 🌸
  • TIFFIsBigTIFF() β€” returns a non-zero value if the file is in BigTIFF style ✨
  • TIFFIsByteSwapped() β€” returns true if the image data is byte-swapped πŸ¦‹
  • TIFFIsCODECConfigured() β€” checks whether we have a working codec πŸ”₯
  • TIFFIsMSB2LSB() β€” bestie this one just says true if the image data you're getting handed back is coming at you with bit 0 as the most significant bit πŸ’…
  • TIFFIsTiled() β€” returns true if the image data is tiled, no cap 🧩
  • TIFFIsUpSampled() β€” gives you a non-zero value if the image data returned through the read interface Routines is being up-sampled. that's it, that's the whole vibe ✨
  • TIFFLastDirectory() β€” non-zero value if the current directory is the last directory in the file; otherwise you get zero, sorry babes πŸ’€
  • TIFFMergeFieldInfo() β€” this one adds application defined TIFF tags into the list of known libtiff tags. very "let me in, i belong here" energy 🫢
  • TIFFNumberOfDirectories() β€” returns the number of directories in a file πŸ“
  • TIFFNumberOfStrips() β€” returns the number of strips in an image 🍫
  • TIFFNumberOfTiles() β€” returns the number of tiles in an image 🧱
  • TIFFOpen() β€” opens a file for reading or writing. the moment, the icon, the classic πŸ‘‘
  • TIFFOpenExt() β€” same deal, opens a file for reading or writing, except with options β€” stuff like re-entrant error and warning handlers may be passed in 🌈
  • TIFFOpenW() β€” opens a TIFF file with a Unicode filename, for read/writing 🌸
  • TIFFOpenWExt() β€” opens a TIFF file with a Unicode filename, for read/writing, and again with options, such as re-entrant error and warning handlers may be passed πŸ¦‹
  • TIFFOpenOptionsAlloc() β€” allocates memory for the TIFFOpenOptions opaque structure. giving it room to breathe fr fr πŸ’–
  • TIFFOpenOptionsFree() β€” releases the allocated memory for TIFFOpenOptions. clean up after yourself bestie, it's giving responsible ✨
  • TIFFOpenOptionsSetMaxSingleMemAlloc() β€” limits the maximum single memory allocation within libtiff. one big bite only πŸ“
  • TIFFOpenOptionsSetMaxCumulatedMemAlloc() β€” limits the maximum cumulated memory allocation within libtiff. it's the total limit, not per-bite πŸŽ€
  • TIFFOpenOptionsSetErrorHandlerExtR() β€” setup of a user-specific and per-TIFF handle (re-entrant) error handler 😭
  • TIFFOpenOptionsSetWarningHandlerExtR() β€” setup of a user-specific and per-TIFF handle (re-entrant) warning handler πŸ™ˆ
  • TIFFPrintDirectory() β€” prints out a description of the current directory πŸ“
  • TIFFRasterScanlineSize() β€” returns the size in bytes of a complete decoded and packed raster scanline πŸ“
  • TIFFRasterScanlineSize64() β€” same thing but it returns the size as uint64_t πŸ”’
  • TIFFRawStripSize() β€” returns the number of bytes in a raw strip 🍫
  • TIFFRawStripSize64() β€” returns the number of bytes in a raw strip, as uint64_t πŸ”’
  • TIFFReadBufferSetup() β€” lets you specify the i/o buffer used for reading 🧺
  • TIFFReadCustomDirectory() β€” reads the custom directory from the given offset and sets the context of the TIFF-handle tif to that custom directory 🎯
  • TIFFReadDirectory() β€” reads the next directory πŸ“–
  • TIFFReadEncodedStrip() β€” reads a strip of data and decodes it, all in one go
  • TIFFReadEncodedTile() β€” same energy, but for a tile of data 🧩
  • TIFFReadEXIFDirectory() β€” reads the EXIF directory sitting at the offset you hand it, and sets the context of the TIFF handle tif to point at that EXIF directory πŸ“Έ
  • TIFFReadFromUserBuffer() β€” this one steps in for TIFFReadEncodedStrip() / TIFFReadEncodedTile() whenever you can supply the buffer for the input data πŸ’…
  • TIFFReadGPSDirectory() β€” reads the GPS directory at the given offset and sets the context of the TIFF handle tif to that GPS directory πŸ“
  • TIFFReadRawStrip() β€” reads a raw strip of data, no decoding, just vibes
  • TIFFReadRawTile() β€” reads a raw tile of data, same deal 🧱
  • TIFFReadRGBAImage() β€” reads an image straight into a fixed-format raster ✨
  • TIFFReadRGBAImageOriented() β€” literally does what TIFFReadRGBAImage() does, except you get to pick the raster origin position πŸ”„
  • TIFFReadRGBAStrip() β€” reads one single strip of a strip-based image into memory, and drops the result into the RGBA raster you supplied yourself πŸŽ€
  • TIFFReadRGBAStripExt() β€” identical to TIFFReadRGBAStrip() but it hands you the stop_on_error parameter too
  • TIFFReadRGBATile() β€” reads one single tile of a tile-based image into memory, storing the result in your very own user-supplied RGBA raster 🧩
  • TIFFReadRGBATileExt() β€” same as TIFFReadRGBATile() but with the stop_on_error parameter added
  • TIFFReadScanline() β€” reads one row of data and decodes it, line by line bestie ➑️
  • TIFFReadTile() β€” reads and decodes a tile of data
  • TIFFRegisterCODEC() β€” lets you override the standard codec for one specific scheme πŸ‘‘
  • TIFFReverseBits() β€” flips all the bits in an array of bytes, little mirror moment πŸͺž
  • TIFFRewriteDirectory() β€” acts a lot like TIFFWriteDirectory(), except you can call it on directories that were previously read or written and that already have an established location in the file, and it relocates that directory to the end of the file πŸ“¦
  • TIFFRGBAImageBegin() β€” sets up the decoder state for TIFFRGBAImageGet
  • TIFFRGBAImageEnd() β€” releases the TIFFRGBAImage decoder state, clean up your room 🧹
  • TIFFRGBAImageGet() β€” reads and decodes an image πŸ–ΌοΈ
  • TIFFRGBAImageOK() β€” tells you whether the image is even readable by TIFFRGBAImageGet (a little vibe check before you commit)
  • TIFFScanlineSize() β€” returns the size of a scanline πŸ“
  • TIFFScanlineSize64() β€” returns the size of a scanline as a uint64_t
  • TIFFSetClientdata() β€” sets the open file's clientdata (that's the file descriptor/handle) and returns the previous value
  • TIFFSetClientInfo() β€” adds or replaces an entry in the
  • (...picking up right where the last cell left off:) clientinfo-list

  • TIFFSetCompressionScheme() β€” sets the compression scheme. choosing the vibe of how your pixels get squeezed πŸ’…
  • TIFFSetDirectory() β€” sets the current directory. like picking which room you're standing in πŸšͺ
  • TIFFSetErrorHandler() β€” sets the error handler function. you're the one deciding who screams when stuff goes wrong 😭
  • TIFFSetErrorHandlerExt() β€” same energy as above, but the error handler function takes a file handle as a parameter 🫢
  • TIFFSetField() β€” sets a tag's value in the current directory. the classic "write the thing" move ✨
  • TIFFSetFileName() β€” sets the file name inside the TIFF-structure and returns the old file name. out with the old, in with the new πŸŽ€
  • TIFFSetFileno() β€” overwrites a copy of the open file's I/O descriptor, and returns the previous value. (refer to the detailed description for the full tea, bestie) πŸ“
  • TIFFSetMode() β€” sets the libtiff open mode in the TIFF-structure and returns the old mode πŸ”
  • TIFFSetSubDirectory() β€” sets the current directory. yes it's giving dΓ©jΓ  vu, they're cousins πŸ¦‹
  • TIFFSetTagExtender() β€” is used to register the merge function for user defined tags as an extender callback with libtiff. bring your own tags, we'll handle them 🌈
  • TIFFSetupStrips() β€” setups or resets strip parameters and strip array memory. a lil factory reset for your strips 🧹
  • TIFFSetWarningHandler() β€” sets the warning handler function. somebody's gotta say "hey, heads up" ⚠️
  • TIFFSetWarningHandlerExt() β€” the same, except the warning handler function takes a file handle as a parameter πŸ’œ
  • TIFFSetWriteOffset() β€” sets the current write offset πŸ“

  • TIFFStripSize() β€” returns the size of a strip πŸ“
  • TIFFStripSize64() β€” returns the equivalent size for a strip of data as uint64_t. big numbers only, no cap πŸ”₯

  • TIFFSwabArrayOfDouble() β€” swaps the bytes of an array of doubles πŸ”„
  • TIFFSwabArrayOfFloat() β€” swaps the bytes of an array of floats 🌊
  • TIFFSwabArrayOfLong() β€” swaps the bytes of an array of longs πŸ’«
  • TIFFSwabArrayOfLong8() β€” swaps the bytes of an array of uint64_t πŸ‘‘
  • TIFFSwabArrayOfShort() β€” swaps the bytes of an array of shorts ⭐
  • TIFFSwabArrayOfTriples() β€” swaps the first and third byte of each triple within an array of bytes. little byte glow-up, one triple at a time πŸŽ€
  • TIFFSwabDouble() β€” swaps the bytes of a double πŸ’…
  • TIFFSwabFloat() β€” swaps the bytes of a float πŸ¦‹
  • TIFFSwabLong() β€” swaps the bytes of a long 🌸
  • TIFFSwabLong8() β€” swaps the bytes of a long long (uint64_t) πŸ’–
  • TIFFSwabShort() β€” swaps the bytes of a short ✨

  • TIFFTileRowSize() β€” returns the size of a row in a tile 🧩
  • TIFFTileRowSize64() β€” returns the size of a row in a tile as uint64_t πŸ”’
  • TIFFTileSize() β€” returns the size of a tile. that's the whole square, bestie, not just one row πŸ‘‘

…and the list just keeps going bestie, because libtiff said "we contain multitudes" and meant it πŸ’…

  • TIFFTileSize64() β€” hands you the size of a tile, but make it uint64_t (big number energy, no overflow tears) ✨
  • TIFFUnlinkDirectory() β€” yanks the directory you point at clean out of the directory chain πŸ”—
  • TIFFUnRegisterCODEC() β€” unregisters that codec, it's done here, thank u next πŸŽ€
  • TIFFUnsetField() β€” clears out the contents of the field in the internal structure, poof, gone πŸ™ˆ
  • TIFFVGetField() β€” returns the tag value in the current directory (the va_list sibling of TIFFGetField()) πŸ“‹
  • TIFFVGetFieldDefaulted() β€” same vibe, returns the tag value in the current directory, but it'll hand you the default when nothing's been set 🫢
  • TIFFVSetField() β€” sets a tag's value in the current directory, va_list style πŸ–ŠοΈ
  • TIFFVStripSize() β€” returns the number of bytes in a strip πŸ“
  • TIFFVStripSize64() β€” returns the number of bytes in a strip with nrows rows of data, as a uint64_t πŸ”’
  • TIFFVTileSize() β€” returns the number of bytes in a row-aligned tile with nrows of data 🧩
  • TIFFVTileSize64() β€” same row-aligned tile with nrows of data, but the answer comes back as a uint64_t number πŸ’«
  • TIFFWarning() β€” the library-wide warning handling function, and it prints to stderr ⚠️
  • TIFFWarningExt() β€” a user-specific library-wide warning handling function that you can pass a file handle to, which gets set to the open TIFF file inside libtiff πŸ“Ž
  • TIFFWarningExtR() β€” the user-specific, re-entrant library warning handling function, and it gets handed its TIFF structure, which contains the pointer to a user-specific data object πŸ”
  • TIFFWriteBufferSetup() β€” sets up the data buffer used for writing raw (encoded) data out to a file 🧺
  • TIFFWriteCheck() β€” verify the file is writable and that the directory information is set up properly. It's the vibe check before you commit πŸ”
  • TIFFWriteCustomDirectory() β€” writes the current custom directory (also EXIF or GPS) to file πŸ—‚οΈ
  • TIFFWriteDirectory() β€” writes the current directory. That's it, that's the whole job πŸ“
  • TIFFWriteEncodedStrip() β€” compresses and writes a strip of data πŸ—œοΈ
  • TIFFWriteEncodedTile() β€” compresses and writes a tile of data 🧱
  • TIFFWriteRawStrip() β€” writes a raw strip of data, no compression shenanigans πŸ₯
  • TIFFWriteRawTile() β€” writes a raw tile of data 🧊
  • TIFFWriteScanline() β€” writes a scanline of data πŸ–ŒοΈ
  • TIFFWriteTile() β€” compresses and writes a tile of data (yes, it's twins with TIFFWriteEncodedTile() up there, they're both iconic) 🌟
  • TIFFXYZToRGB() β€” performs the CIE XYZ to RGB conversion 🌈
  • TIFFYCbCrtoRGB() β€” performs the YCbCr to RGB conversion 🎨
  • TIFFYCbCrToRGBInit() β€” initializes the YCbCr to RGB conversion state, so the conversion above has somewhere to live πŸ› οΈ

🧰 LIBTIFF AUXILIARY FUNCTIONS

okay so these are the auxiliary besties β€” the backstage crew πŸŽ€ not the flashy main-character functions, but the ones keeping everything from imploding. here's the whole squad, no skips:

  • _TIFFCheckMalloc() β€” checks for integer overflow before it dynamically allocates a memory buffer. safety first, always πŸ’…
  • _TIFFCheckRealloc() β€” same energy, but the overflow check happens before it dynamically reallocates a memory buffer.
  • _TIFFClampDoubleToUInt32() β€” clamps double values into the range of uint32_t, i.e. 0 .. 0xFFFFFFFF. no escaping the box, bestie πŸ”’
  • _TIFFfree() β€” free a memory buffer. bye girl πŸ‘‹
  • _TIFFGetExifFields() β€” returns a pointer to the libtiff internal definition list of the EXIF tags.
  • _TIFFGetGpsFields() β€” returns a pointer to the libtiff internal definition list of the GPS tags. yes, the location ones πŸ—ΊοΈ
  • _TIFFmalloc() β€” dynamically allocate a memory buffer.
  • _TIFFmemcmp() β€” compares the contents of memory buffers.
  • _TIFFmemcpy() β€” copies the contents of one buffer to another.
  • _TIFFmemset() β€” fills a memory buffer with a constant byte.
  • _TIFFMultiply32() β€” checks for an integer overflow of the multiplication result of uint32_t, and returns the multiplication result, or 0 if an overflow would happen.
  • _TIFFMultiply64() β€” same thing but the multiplication result of uint64_t, and again returns the multiplication result, or 0 if an overflow would happen.
  • _TIFFrealloc() β€” dynamically reallocate a memory buffer.
  • _TIFFRewriteField() β€” rewrites a field in the directory on disk without regard to updating the TIFF directory structure in memory. that's it, that's the whole description. it does not touch the in-memory copy, fr fr πŸ™ˆ

🏷️ TAG USAGE

want the receipts on which TIFF tags the library actually recognizes? for a table of TIFF tags recognized by the library, refer to LibTIFF Coverage of the TIFF 6.0 Specification ✨ go read it, it's giving very thorough.


🧚 PSEUDO TAGS

okay so this is the fun part πŸ‘‘

in addition to the normal TIFF tags, the library supports a whole collection of tags whose values lie in a range outside the valid range of TIFF tags. these are termed pseudo-tags, and they're used to control various codec-specific functions within the library. think of them as the secret menu items β€” not real TIFF tags, but the library understands them 🫢

the table below summarizes the defined pseudo-tags.

…and that table is right where we're headed next, so don't you dare close the tab πŸ’œ

🌈 LIBTIFF SUPPORTED TAGS 🌈

okay bestie, here's the tea on which tags are actually supported, who reads and writes them, and what they do 🫢 every single one of these is R/W (read and write), no cap:

  • TIFFTAG_FAXMODE β€” codec: G3 Β· R/W Β· general codec operation
  • TIFFTAG_FAXFILLFUNC β€” codec: G3/G4 Β· R/W Β· bitmap fill function
  • TIFFTAG_JPEGQUALITY β€” codec: JPEG Β· R/W Β· compression quality control
  • TIFFTAG_JPEGCOLORMODE β€” codec: JPEG Β· R/W Β· control colorspace conversions
  • TIFFTAG_JPEGTABLESMODE β€” codec: JPEG Β· R/W Β· control contents of JPEGTables tag
  • TIFFTAG_ZIPQUALITY β€” codec: Deflate Β· R/W Β· compression quality level
  • TIFFTAG_PIXARLOGDATAFMT β€” codec: PixarLog Β· R/W Β· user data format
  • TIFFTAG_PIXARLOGQUALITY β€” codec: PixarLog Β· R/W Β· compression quality level
  • TIFFTAG_SGILOGDATAFMT β€” codec: SGILog Β· R/W Β· user data format

TIFFTAG_FAXMODE 🎞️

Controls how the Group 3 codec operates. The possible values are independent bits, so you can combine them by or'ing them together:

  • FAXMODE_CLASSIC β€” enable old-style format in which the RTC is written at the end of the last strip
  • FAXMODE_NORTC β€” the opposite of FAXMODE_CLASSIC; also called FAXMODE_CLASSF
  • FAXMODE_NOEOL β€” do not write EOL codes at the start of each row of data
  • FAXMODE_BYTEALIGN β€” align each encoded row to an 8-bit boundary
  • FAXMODE_WORDALIGN β€” align each encoded row to an 16-bit boundary

The default value is dependent on the compression scheme; this pseudo-tag is used by the various G3 and G4 codecs to share code. πŸ’…

TIFFTAG_FAXFILLFUNC πŸ–ŒοΈ

Controls the function used to convert arrays of black and white runs to packed bit arrays. This hook can be used to image decoded scanlines in multi-bit depth rasters (e.g. for display in colormap mode) or for other purposes. The default value is a pointer to a builtin function that images packed bilevel data.

TIFFTAG_IPTCNEWSPHOTO πŸ“°

This tag contains image metadata per the IPTC newsphoto spec: Headline, captioning, credit, etc... Used by most wire services.

TIFFTAG_PHOTOSHOP 🎨

This tag contains Photoshop captioning information and metadata. Photoshop uses in parallel and redundantly alongside IPTCNEWSPHOTO information.

TIFFTAG_JPEGQUALITY πŸ“Έ

Controls the compression quality level used in the baseline algorithm. Note that quality levels are in the range 0-100 with a default value of 75.

TIFFTAG_JPEGCOLORMODE 🌈

Controls whether or not conversion is done between RGB and YCbCr colorspaces. Possible values are:

  • JPEGCOLORMODE_RAW β€” do not convert, and
  • JPEGCOLORMODE_RGB β€” convert to/from RGB

The default value is JPEGCOLORMODE_RAW.

TIFFTAG_JPEGTABLESMODE πŸ—‚οΈ

Controls the information written in the JPEGTables tag. Possible values are independent bits that can be combined by or'ing them together:

  • JPEGTABLESMODE_QUANT β€” include quantization tables, and
  • JPEGTABLESMODE_HUFF β€” include Huffman encoding tables.

The default value is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF.

TIFFTAG_ZIPQUALITY πŸ—œοΈ

Controls the compression technique used by the Deflate codec. Quality levels are in the range 1-9, with larger numbers yielding better compression at the cost of more computation. The default quality level is 6, which yields a good time-space tradeoff. (iconic behavior honestly ✨)

TIFFTAG_PIXARLOGDATAFMT 🧚

Controls the format of user data passed in to the PixarLog codec when encoding and passed out from when decoding. Possible values are:

  • PIXARLOGDATAFMT_8BIT β€” for 8-bit unsigned pixels
  • PIXARLOGDATAFMT_8BITABGR β€” for 8-bit unsigned ABGR-ordered pixels
  • PIXARLOGDATAFMT_11BITLOG β€” for 11-bit log-encoded raw data
  • PIXARLOGDATAFMT_12BITPICIO β€” for 12-bit PICIO-compatible data
  • PIXARLOGDATAFMT_16BIT β€” for 16-bit signed samples, and
  • PIXARLOGDATAFMT_FLOAT β€” for 32-bit IEEE floating point samples.

TIFFTAG_PIXARLOGQUALITY πŸ”₯

Controls the compression technique used by the PixarLog codec. This value is treated identically to TIFFTAG_ZIPQUALITY; see the above description.

TIFFTAG_SGILOGDATAFMT 🌸

Controls the format of client data passed in to the SGILog codec when encoding and passed out from when decoding. Possible values are:

  • SGILOGDATAFMT_FLTXYZ β€” for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels
  • SGILOGDATAFMT_16BITLUV β€” for 16-bit encoded Luv pixels
  • SGILOGDATAFMT_32BITRAW, SGILOGDATAFMT_24BITRAW β€” for no conversion of data
  • SGILOGDATAFMT_8BITRGB β€” for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data)
  • SGILOGDATAFMT_FLTY β€” for converting between LogL and 32-bit IEEE floating valued Y pixels
  • SGILOGDATAFMT_16BITL β€” for 16-bit encoded L pixels, and
  • SGILOGDATAFMT_8BITGRY β€” for returning 8-bit greyscale data (valid only when decoding LogL-encoded data).

✨ DIAGNOSTICS ✨

All error messages are directed through the TIFFErrorExtR() routine. By default, messages are directed to stderr in the form:

module: message\n

Warning messages are likewise directed through the TIFFWarningExtR() routine. 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

fax2tiff, pal2rgb, ppm2tiff, rgb2ycbcr, raw2tiff, tiff2bw, tiffdither, tiffdump, tiffcp, tiffcmp, tiffgt, tiffinfo, tiffmedian, tiffsplit,

"Tag Image File Format Specification Revision 6.0", an Aldus Technical Memorandum.

"The Spirit of TIFF Class F", an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies.


πŸ’€ BUGS πŸ’€

  • The library does not support multi-sample images where some samples have different bits/sample.
  • The library does not support random access to compressed data that is organized with more than one row per tile or strip.
not me listing the Ls, but fr fr these are real limitations so don't come for the library when they bite you 😭

🫢 AUTHOR 🫢

LibTIFF contributors


1988-2025, LibTIFF contributors


and that's a wrap bestie!! this whole thing was LibTIFF version 4.7, dated Jun 27, 2026, aka LIBTIFF(3tiff) β€” go forth and tag your TIFFs responsibly πŸ’–βœ¨ slay, periodt, bye πŸ¦‹