|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Create, release, select, query, and unlink directories. More...
Functions | |
| tdir_t | TIFFCurrentDirectory (TIFF *tif) |
| Read the cached index of the current directory. | |
| tdir_t | TIFFNumberOfDirectories (TIFF *tif) |
| Count reachable main-chain directories from the cached file header. | |
| uint64_t | TIFFCurrentDirOffset (TIFF *tif) |
| Read the cached file offset of the current directory. | |
| void | TIFFFreeDirectory (TIFF *tif) |
| Release the current directory's owned values and codec state. | |
| int | TIFFCreateDirectory (TIFF *tif) |
| Replace current values with a fresh in-memory image directory. | |
| int | TIFFCreateCustomDirectory (TIFF *tif, const TIFFFieldArray *infoarray) |
| Replace current values with a fresh custom metadata directory. | |
| int | TIFFCreateEXIFDirectory (TIFF *tif) |
| Create a fresh in-memory EXIF metadata directory. | |
| int | TIFFCreateGPSDirectory (TIFF *tif) |
| Create a fresh in-memory EXIF GPS metadata directory. | |
| int | TIFFLastDirectory (TIFF *tif) |
| Test whether the cached next-directory link is zero. | |
| int | TIFFSetDirectory (TIFF *tif, tdir_t dirn) |
| Select and read an image directory by its main-chain index. | |
| int | TIFFSetSubDirectory (TIFF *tif, uint64_t diroff) |
| Select and read an image directory at a file offset. | |
| int | TIFFUnlinkDirectory (TIFF *tif, tdir_t dirn) |
| Remove an image directory from the on-file main chain. | |
Create, release, select, query, and unlink directories.
See Directory creation and navigation for numbering, failure states, and side effects.
|
extern |
Replace current values with a fresh custom metadata directory.
Discards current directory values and codec state through TIFFFreeDirectory(), then installs defaults and the image schema through TIFFDefaultDirectory(). Invalidates borrowed values and replaceable descriptors. Does not save dirty values or write an IFD; use this only when discarding them is intended. No new TIFF handle is allocated. Setup may allocate and invoke the process-wide tag extender and codec setup, with diagnostics but no reliable status propagation. Subsequently replaces the image field table with the supplied custom schema; the extender does not extend the final custom table. A NULL infoarray is diagnosed and leaves the image schema from TIFFDefaultDirectory() in place; the remaining resets still occur. Clears current/next/data offsets, sets the index to (tdir_t)UINT_MAX, destroys directory maps, and forces the next indexed selection to start from the main-chain header. Descriptors/names remain borrowed and must outlive their use. The schema record itself is only read during setup. The new metadata must later be written with TIFFWriteCustomDirectory() and linked by the appropriate parent tag; creation does not link it.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
| [in] | infoarray | Valid private schema with long-lived descriptors and names, or NULL (rejected as described above); TIFFFieldArray is opaque in the public header. |
Definition at line 2258 of file tif_dir.c.
References _TIFFCleanupIFDOffsetAndNumberMaps(), _TIFFSetupFields(), tiff::tif_curdir, tiff::tif_curoff, tiff::tif_diroff, tiff::tif_nextdiroff, tiff::tif_setdirectory_force_absolute, TIFF_NON_EXISTENT_DIR_NUMBER, TIFFDefaultDirectory(), TIFFErrorExtR(), TIFFFreeDirectory(), and TRUE.
Referenced by TIFFCreateEXIFDirectory(), and TIFFCreateGPSDirectory().
|
extern |
Replace current values with a fresh in-memory image directory.
Discards current directory values and codec state through TIFFFreeDirectory(), then installs defaults and the image schema through TIFFDefaultDirectory(). Invalidates borrowed values and replaceable descriptors. Does not save dirty values or write an IFD; use this only when discarding them is intended. No new TIFF handle is allocated. Setup may allocate and invoke the process-wide tag extender and codec setup, with diagnostics but no reliable status propagation. Clears current/next directory and image-data offsets and marks the directory unwritten. The cached directory index, directory maps, and other write state are not comprehensively reset; this is not equivalent to reopening a handle.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2246 of file tif_dir.c.
References FALSE, TIFFDirectory::td_iswrittentofile, tiff::tif_curoff, tiff::tif_dir, tiff::tif_diroff, tiff::tif_nextdiroff, TIFFDefaultDirectory(), and TIFFFreeDirectory().
Referenced by TIFFWriteDirectorySec().
|
extern |
Create a fresh in-memory EXIF metadata directory.
Delegates to TIFFCreateCustomDirectory() with the built-in EXIF schema and all its discard, pointer-invalidation, index/map reset, callback, and failure rules. The caller needs no private schema definition. Does not persist or link the metadata directory; write/link it separately.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2296 of file tif_dir.c.
References _TIFFGetExifFields(), exifFieldArray, and TIFFCreateCustomDirectory().
|
extern |
Create a fresh in-memory EXIF GPS metadata directory.
Delegates to TIFFCreateCustomDirectory() with the built-in EXIF GPS schema and all its discard, pointer-invalidation, index/map reset, callback, and failure rules. The caller needs no private schema definition. Does not persist or link the metadata directory; write/link it separately.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2306 of file tif_dir.c.
References _TIFFGetGpsFields(), gpsFieldArray, and TIFFCreateCustomDirectory().
Read the cached index of the current directory.
Reads state without I/O, allocation, diagnostics, or ownership transfer. A main-chain read uses zero-based numbering; a newly entered unrecognised SubIFD chain starts at zero. After writing an image directory the index can describe the last written IFD while the in-memory directory is fresh. Creation of an ordinary directory preserves the old index. A failed read can leave an index without a fully valid directory. See Directory creation and navigation for these distinctions.
| [in] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 906 of file tif_open.c.
References tiff::tif_curdir.
|
extern |
Read the cached file offset of the current directory.
Reads state without I/O, allocation, diagnostics, or ownership transfer. A nonzero result can identify a directory whose read later failed; zero can mean a fresh directory or stepping beyond the chain. It is not proof that current tag values came from that offset. See Directory creation and navigation.
| [in] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2814 of file tif_dir.c.
References tiff::tif_diroff.
|
extern |
Release the current directory's owned values and codec state.
Invokes codec cleanup, clears presence bits, and releases directory-owned arrays, strings, custom-value storage, deferred strile entries, and IFD-size bookkeeping. Borrowed pointers into this storage become invalid. Does not free/close the handle or its client I/O, persist dirty values, dispose the field schema, or fully reset scalar values, offsets, and indices. Initialise a new directory before using it for normal tag/image operations. Core cleanup returns no status; codec callbacks may have their own diagnostics/side effects.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2165 of file tif_dir.c.
References _TIFFfreeExt(), _TIFFmemset(), CleanupField, FALSE, FIELD_YCBCRPOSITIONING, FIELD_YCBCRSUBSAMPLING, TIFFDirectory::td_colormap_alloc, TIFFDirectory::td_colormap_count, TIFFDirectory::td_customValueCount, TIFFDirectory::td_customValues, TIFFDirectory::td_dirdatasize_Noffsets, TIFFDirectory::td_dirdatasize_offsets, TIFFDirectory::td_dirdatasize_read, TIFFDirectory::td_dirdatasize_write, TIFFDirectory::td_fieldsset, TIFFDirectory::td_iswrittentofile, TIFFDirectory::td_stripbytecount_entry, TIFFDirectory::td_stripoffset_entry, TIFFDirectory::td_stripoffsetbyteallocsize, TIFFDirectory::td_transferfunction_count, tiff::tif_cleanup, tiff::tif_dir, TIFFClrFieldBit, and TIFFTagValue::value.
Referenced by TIFFCleanup(), TIFFCreateCustomDirectory(), TIFFCreateDirectory(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFUnlinkDirectory(), and TIFFWriteDirectorySec().
|
extern |
Test whether the cached next-directory link is zero.
Does not scan or validate the file. A fresh unwritten directory also satisfies this test, and a loop-truncated chain can appear finished. No allocation, I/O, mutation, diagnostic, or ownership transfer occurs.
| [in] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2820 of file tif_dir.c.
References tiff::tif_nextdiroff.
Count reachable main-chain directories from the cached file header.
Walks directory links without loading their tag values, starting from the cached header rather than the current SubIFD. Does not count unwritten directories or traverse SubIFD arrays/custom metadata. Updates index/offset maps and the cached directory count; leaves current tag storage/index unchanged but can move client I/O position and allocate map storage. Read errors dispatch diagnostics and return the prefix counted so far. A detected next-link loop warns and is treated as the chain end. Map-creation exhaustion can be diagnosed while traversal continues without full loop tracking. A zero or partial count is not a separate error status. No ownership transfers.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
Definition at line 2623 of file tif_dir.c.
References TIFFHeaderUnion::big, TIFFHeaderUnion::classic, tiff::tif_curdircount, tiff::tif_flags, tiff::tif_header, TIFF_BIGTIFF, TIFFHeaderClassic::tiff_diroff, TIFFHeaderBig::tiff_diroff, and TIFFAdvanceDirectory().
Referenced by _TIFFGetDirNumberFromOffset(), and TIFFWriteDirectorySec().
Select and read an image directory by its main-chain index.
Uses a cached offset, relative stepping, or traversal from the cached header as appropriate. After leaving a custom/SubIFD context it clears those maps and starts from the main-chain header. It does not select a SubIFD by array position. Does not save dirty values first. Successful reading replaces directory/codec state and invalidates borrowed values and replaceable descriptors. Once reading starts, failure can leave changed offsets, index, next-link, schema, flags, and partially loaded values; there is no rollback to the old directory. Unreachable indices can fail earlier with old values still present but altered maps, traversal flags, or I/O position. Diagnostics follow traversal/reader failures; absence can return zero silently. No ownership transfers and no errno guarantee is provided.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
| [in] | dirn | Zero-based main-chain directory index. |
Definition at line 2648 of file tif_dir.c.
References _TIFFCleanupIFDOffsetAndNumberMaps(), _TIFFGetOffsetFromDirNumber(), TIFFHeaderUnion::big, TIFFHeaderUnion::classic, FALSE, tiff::tif_curdir, tiff::tif_diroff, tiff::tif_flags, tiff::tif_header, tiff::tif_nextdiroff, tiff::tif_setdirectory_force_absolute, TIFF_BIGTIFF, TIFFHeaderClassic::tiff_diroff, TIFFHeaderBig::tiff_diroff, TIFF_NON_EXISTENT_DIR_NUMBER, TIFFAdvanceDirectory(), and TIFFReadDirectory().
|
extern |
Select and read an image directory at a file offset.
Use this for image SubIFDs; EXIF/GPS/custom metadata requires the matching custom reader/schema. An offset known to the maps retains its mapped index. An unrecognised successful offset starts a new chain indexed at zero, clears/reseeds maps, and forces a later TIFFSetDirectory() to restart at the main-chain header. The lookup may first scan main-chain links. Failures may still change traversal state, and a final map-registration failure can follow a successful directory read. A zero offset is a special state operation: clears current/next offsets, sets the index unknown and unwritten flag, keeps old tag values, performs no directory read, and returns zero. Does not save dirty values first. Successful reading replaces directory/codec state and invalidates borrowed values and replaceable descriptors. Once reading starts, failure can leave changed offsets, index, next-link, schema, flags, and partially loaded values; there is no rollback to the old directory. An unreadable or loop-detected offset can fail before old values are replaced, but after the map lookup has scanned the main chain and changed maps, flags, or I/O position. Diagnostics follow traversal/reader failures. No ownership transfers and no errno guarantee is provided.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
| [in] | diroff | Image-IFD offset in file bytes, or zero for the special no-current-offset operation. |
Definition at line 2744 of file tif_dir.c.
References _TIFFCheckDirNumberAndOffset(), _TIFFCleanupIFDOffsetAndNumberMaps(), _TIFFGetDirNumberFromOffset(), FALSE, TIFFDirectory::td_iswrittentofile, tiff::tif_curdir, tiff::tif_dir, tiff::tif_nextdiroff, tiff::tif_setdirectory_force_absolute, TIFF_NON_EXISTENT_DIR_NUMBER, TIFFReadDirectory(), and TRUE.
Remove an image directory from the on-file main chain.
Requires a writable handle and a reachable main-chain entry. Patches the preceding link (or header) to the following directory; does not reclaim the removed IFD or image-data bytes, truncate the file, or update references such as SubIFD arrays. Does not flush current dirty values/data first. After a successful link write, releases owned raw-buffer/directory storage and codec state, installs defaults, clears write/current/next/last offsets and maps, and leaves a fresh directory intended for appending. Borrowed storage is invalidated and cached counts/index change. Seek/write/chain failures dispatch diagnostics but can leave changed maps, position, or file bytes; no rollback is attempted. The patch seek result is not independently checked, and post-write default-setup errors do not change the success result. No handle ownership transfers.
| [in,out] | tif | Non-NULL live handle; caller must serialise access. |
| [in] | dirn | One-based main-chain position: the first directory is 1, unlike TIFFSetDirectory(). Zero is rejected. |
Definition at line 2828 of file tif_dir.c.
References _TIFFCleanupIFDOffsetAndNumberMaps(), _TIFFfreeExt(), TIFFHeaderUnion::big, TIFFHeaderUnion::classic, tiff::tif_curdir, tiff::tif_curdircount, tiff::tif_curoff, tiff::tif_diroff, tiff::tif_flags, tiff::tif_header, tiff::tif_lastdiroff, tiff::tif_mode, tiff::tif_nextdiroff, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdata, tiff::tif_rawdataloaded, tiff::tif_rawdataoff, tiff::tif_rawdatasize, TIFF_BEENWRITING, TIFF_BIGTIFF, TIFF_BUF4WRITE, TIFF_BUFFERSETUP, TIFFHeaderClassic::tiff_diroff, TIFFHeaderBig::tiff_diroff, TIFF_MYBUFFER, TIFF_NON_EXISTENT_DIR_NUMBER, TIFF_POSTENCODE, TIFF_SWAB, TIFFAdvanceDirectory(), TIFFDefaultDirectory(), TIFFErrorExtR(), TIFFFreeDirectory(), TIFFSeekFile, TIFFSwabLong(), TIFFSwabLong8(), and WriteOK.