TIFFREADDIRECTORY(3tiff)
β¨ TIFFREADDIRECTORY β¨
okay bestie, so this is the 3tiff manual page for TIFFReadDirectory from the LibTIFF crew, and it's genuinely one of the most useful little functions in the whole library, no cap π
πΈ NAME πΈ
TIFFReadDirectory β get the contents of the next directory in an open TIFF file π¦
π SYNOPSIS π
#include <tiffio.h>
int TIFFReadDirectory(TIFF *tif)
π DESCRIPTION π
okay so here's the vibe: this function reads the next directory in the file you specify and makes it the current directory. that's it, that's the whole job, and she does it flawlessly β¨
the tea is that applications only need to call TIFFReadDirectory() when they want to read multiple subfiles in a single TIFF file β because the first directory in a file is automatically read for you when TIFFOpen() is called. so like, directory number one is already handled, bestie, you just gotta come back for the rest π
π§ NOTES π§
okay so this part is important, listen up π«Ά
if the library is compiled with STRIPCHOP_SUPPORT enabled, then images that have a single uncompressed strip or tile of data are automatically treated as if they were made up of multiple strips or tiles of approximately 8 kilobytes each. iconic behaviour honestly.
this operation is done only in-memory β it does not alter the contents of the file. phew, your file is safe π
however (and this is the part where you gotta pay attention, fr fr), the construction of the "chopped strips" is visible to the application through the number of strips [tiles] returned by TIFFNumberOfStrips() [TIFFNumberOfTiles()]. so like, the count you get back reflects the chopping, not what's literally on disk. iykyk π
π RETURN VALUES π
- if the next directory was successfully read β
1is returned, slay β¨ - otherwise β
0is returned if an error was encountered, or if there are no more directories to be read.
(yes bestie, 0 is doing double duty here, that's just how it is π)
π₯ DIAGNOSTICS π₯
all error messages are directed to the TIFFErrorExtR() routine. likewise, warning messages are directed to the TIFFWarningExtR() routine. so if something's up, that's where it gets announced π’
here's the full lineup of messages, no skips, no shortcuts, we're listing every single one because that's the whole point π
Seek error accessing TIFF directory:an error occurred while positioning to the location of the directory.Wrong data type %d for field "%s":the tag entry in the directory had an incorrect data type. for example, anImageDescriptiontag with aSHORTdata type.TIFF directory is missing required "%s" field:the specified tag is required to be present by the TIFF 5.0 specification, but is missing. the directory is (usually) unusable. π¬%s: Rational with zero denominator:a directory tag has aRATIONALvalue whose denominator is zero. math said no π«Incorrect count %d for field "%s" (%lu, expecting %lu); tag ignored:the specified tag's count field is bad. for example, a count other than1for aSubFileTypetag. so it just gets ignored, moving on πCannot handle different per-sample values for field "%s":the tag hasSamplesPerPixelvalues and they are not all the same; e.g.BitsPerSample. the library is unable to handle images of this sort. sorry bestie πCount mismatch for field "%s"; expecting %d, got %d:the count field in a tag does not agree with the number expected by the library. this should never happen, so if it does, the library refuses to read the directory. πInvalid TIFF directory; tags are not sorted in ascending order:the directory tags are not properly sorted as specified in the TIFF 5.0 specification. this error is not fatal though, so like, we survive π«ΆIgnoring unknown field with tag %d (0x%x):an unknown tag was encountered in the directory; the library ignores all such tags. not our problem, not our business πTIFF directory is missing required "ImageLength" field:the image violates the specification by not having a necessary field. there is no way for the library to recover from this error. game over πTIFF directory is missing required "PlanarConfig" field:the image violates the specification by not having a necessary field. there is no way for the library to recover from this error.TIFF directory is missing required "StripOffsets" field:the image has multiple strips, but is missing the tag that specifies the file offset to each strip of data. there is no way for the library to recover from this error.TIFF directory is missing required "TileOffsets" field:the image has multiple tiles, but is missing the tag that specifies the file offset to each tile of data. there is no way for the library to recover from this error.TIFF directory is missing required "StripByteCounts" field:the image has multiple strips, but is missing the tag that specifies the size of each strip of data. there is no way for the library to recover from this error.TIFF directory is missing required "StripByteCounts" field, calculating from imagelength:the image violates the specification by not having a necessary field. however, when the image is comprised of only one strip or tile, the library will estimate the missing value based on the file size. ok so she's resourceful πBogus "StripByteCounts" field, ignoring and calculating from imagelength:certain vendors violate the specification by writing zero for theStripByteCountstag when they want to leave the value unspecified. if the image has a single strip, the library will estimate the missing value based on the file size. vendors really said "idk figure it out" and the library said "bet" π
π¦ SEE ALSO π¦
TIFFOpen(3tiff)TIFFCreateDirectory(3tiff)TIFFCustomDirectory(3tiff)TIFFquery(3tiff)TIFFWriteDirectory(3tiff)TIFFSetDirectory(3tiff)- Multi Page / Multi Image TIFF
libtiff(3tiff)
π AUTHOR π
LibTIFF contributors π
β COPYRIGHT β
1988-2025, LibTIFF contributors
okay bestie that's the whole page, we ate and left no crumbs π β¨ this was LibTIFF 4.7, dated Jun 27, 2026 β go read some directories, you've got this ππ«Ά
π¦ 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