TIFFSETDIRECTORY(3tiff)

πŸ’– TIFFSETDIRECTORY β€” setting the current directory for an open TIFF file πŸ’–

okay bestie, welcome to the LibTIFF corner of the manual, page TIFFSETDIRECTORY(3tiff). this one is all about telling your open TIFF file which directory you wanna be looking at rn. it's giving file-navigation main character energy πŸ—‚οΈβœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <tiffio.h>

int TIFFSetDirectory(TIFF *tif, tdir_t dirnum)

int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)

🌸 DESCRIPTION 🌸

so like, TIFFSetDirectory() does two things at once and honestly? slay. it changes the current directory and reads its contents with TIFFReadDirectory(). the parameter dirnum tells it which subfile/directory you want, as an integer number β€” and heads up, the first directory is numbered zero, because of course it is, zero-indexing stays undefeated πŸ’…

and here's the lil catch: TIFFSetDirectory() only works with main-IFD chains, because it always starts with the first main-IFD, and that's exactly how it's able to reset the SubIFD reading chain back to the main-IFD chain. it's a reset girlie 🫢

then there's TIFFSetSubDirectory(), which is basically TIFFSetDirectory()'s sibling β€” same vibe, except the directory is specified as a file offset instead of an index. and you need this one for accessing subdirectories linked through a SubIFD tag. (see MultiPage SubIFD) πŸ”₯


now, the directory query functions β€” TIFFCurrentDirectory(), TIFFCurrentDirOffset(), TIFFLastDirectory() and TIFFNumberOfDirectories() β€” retrieve information about directories in an open TIFF file. cute, right? but bestie, listen:

⚠️ be aware that until a directory is not written to file AND read back, the query functions won't retrieve the correct information! no cap, that's a real gotcha 😭

✨ RETURN VALUES ✨

  • on a successful return, 1 is returned. periodt πŸ’š
  • otherwise, 0 is returned if dirnum or diroff specifies a non-existent directory, or if an error was encountered while reading the directory's contents. πŸ’€

πŸŽ€ DIAGNOSTICS πŸŽ€

all error messages are directed to the TIFFErrorExtR() routine. she's the one handling all the drama.

  • "%s: Error fetching directory count" β€” an error was encountered while reading the "directory count" field. πŸ™ˆ
  • "%s: Error fetching directory link" β€” an error was encountered while reading the "link value" that points to the next directory in a file. πŸ”—

🌈 SEE ALSO 🌈

  • TIFFquery (3tiff)
  • TIFFOpen (3tiff)
  • TIFFCreateDirectory (3tiff)
  • TIFFCustomDirectory (3tiff)
  • TIFFWriteDirectory (3tiff)
  • TIFFReadDirectory (3tiff)
  • Multi Page / Multi Image TIFF
  • libtiff (3tiff)

πŸ‘‘ AUTHOR πŸ‘‘

LibTIFF contributors β€” icons only, fr fr 🫢

1988-2025, LibTIFF contributors


okay that's the whole page, bestie, you ate that πŸ“βœ¨ this was page TIFFSETDIRECTORY(3tiff) from LibTIFF version 4.7, dated Jun 27, 2026. go set some directories, you've got this πŸ’…πŸ’–

mwah πŸ’‹