TIFFCREATEDIRECTORY(3tiff)

πŸ’– TIFFCREATEDIRECTORY πŸ’– (that's a 3tiff man page bestie, from the LibTIFF crew)

okay so. you're out here making directories inside TIFF files and you need the tea?? say less. this is TIFFCreateDirectory and its little friend group β€” the routines that create a directory and pull info about directories. let's get into it πŸŽ€


✨ NAME ✨

TIFFCreateDirectory β€” routines to create a directory and retrieve information about directories πŸ—‚οΈβœ¨


🌸 SYNOPSIS 🌸

#include <tiffio.h>
int TIFFCreateDirectory(TIFF *tif)

int TIFFFreeDirectory(TIFF *tif)

int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)

πŸ¦‹ DESCRIPTION πŸ¦‹

The following routines create or release a directory. iconic behaviour honestly.

TIFFCreateDirectory() sets up for a directory in an open TIFF file. the newly created directory will not exist on the file till TIFFWriteDirectory(), TIFFCheckpointDirectory(), TIFFFlush() or TIFFClose() is called. Also, TIFFWriteDirectory() also creates a new directory, frees the *tif structure and sets up a new one. it's giving double duty πŸ’…

TIFFFreeDirectory() releases allocated storage associated with a directory, especially custom-fields. however, the main part of the directory is not touched. Routine TIFFCleanup() calls TIFFFreeDirectory() to release the directory part of the tif structure. teamwork fr fr 🫢

TIFFUnlinkDirectory() unlinks the specified directory from the directory chain. The parameter dirn specifies the subfile/directory as an integer number, with the first directory numbered one (1). 🚨 This is different to TIFFSetDirectory() or TIFFCurrentDirectory() where the first directory starts with zero (0). yes bestie, the off-by-one is real, watch your step 😭

Directory query functions TIFFCurrentDirectory(), TIFFCurrentDirOffset(), TIFFLastDirectory() and TIFFNumberOfDirectories() retrieve information about directories in an open TIFF file. Be aware that until a directory is not written to file AND read back, the query functions won't retrieve the correct information! not me warning you twice about this, i'm just looking out for you πŸ’€


πŸ’… NOTES πŸ’…

Be aware:

  • that until a directory is not written to file AND read back, the query functions won't retrieve the correct information! πŸ™ˆ
  • that the newly created directory will not exist on the file till TIFFWriteDirectory(), TIFFCheckpointDirectory(), TIFFFlush() or TIFFClose() has been called.
  • that TIFFCreateDirectory() and TIFFWriteDirectory() create a new directory, free the *tif structure and set up a new one.
  • that unlike TIFFWriteDirectory(), TIFFCheckpointDirectory() does not free up the directory data structures in memory.

After libtiff version 4.6.0 TIFFCreateDirectory() also releases the directory part of the tif structure by calling TIFFFreeDirectory(), which should have been called by the user application before creating a new directory. so yeah, that's on you to have handled already, no cap 🧚


πŸ”₯ DIAGNOSTICS πŸ”₯

All error messages are directed to the TIFFErrorExtR() routine. Likewise, warning messages are directed to the TIFFWarningExtR() routine. they're literally just the messengers, don't shoot them πŸ’Œ


πŸ‘‘ SEE ALSO πŸ‘‘

  • libtiff (3tiff)
  • TIFFCustomDirectory (3tiff)
  • TIFFquery (3tiff)
  • TIFFSetDirectory (3tiff)
  • TIFFWriteDirectory (3tiff)

🌈 AUTHOR 🌈

LibTIFF contributors 🫢 absolute main characters.


1988-2025, LibTIFF contributors


okay that's the whole page bestie, go forth and unlink responsibly πŸ’–βœ¨

this was LibTIFF version 4.7, dated Jun 27, 2026 β€” mwah, stan, periodt πŸŽ€