LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Functions
IFD reading

Load image, custom, EXIF, and GPS directory values. More...

Collaboration diagram for IFD reading:

Functions

int TIFFReadDirectory (TIFF *tif)
 Read and install the next image directory.
 
int TIFFReadCustomDirectory (TIFF *tif, toff_t diroff, const TIFFFieldArray *infoarray)
 Read metadata using an explicit custom field schema.
 
int TIFFReadEXIFDirectory (TIFF *tif, toff_t diroff)
 Read a EXIF metadata directory.
 
int TIFFReadGPSDirectory (TIFF *tif, toff_t diroff)
 Read a EXIF GPS metadata directory.
 

Detailed Description

Load image, custom, EXIF, and GPS directory values.

See Reading and writing IFDs for recovery, ownership, and partial failure semantics.

Function Documentation

◆ TIFFReadCustomDirectory()

int TIFFReadCustomDirectory ( TIFF *  tif,
toff_t  diroff,
const TIFFFieldArray *  infoarray 
)
extern

Read metadata using an explicit custom field schema.

Fetches an IFD at the supplied byte offset, then frees old values and installs defaults followed by the supplied schema. The schema record is only read during setup; descriptors/names remain borrowed while registered. Allocates/copies owned values, can register anonymous fields, and may seek/read or access mapped data. Duplicate, unknown-type, and wrong-count handling can skip/trim tags with diagnostics. Individual tag-fetch/set failures are ignored by the top-level loop, so success can coexist with errors and omitted values. The reader does not traverse a custom NextIFD chain or link this IFD into a parent. It does not save dirty old values. Even an early fetch failure can change the current offset; later failure can leave a partly replaced schema/values. No rollback or general errno guarantee. Borrowed old values/descriptors can be invalidated. Successful completion forces subsequent indexed selection to restart from the main header; index/next-link caches are not comprehensively reset. See Reading and writing IFDs.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]diroffNonzero custom-IFD offset in file bytes.
[in]infoarrayNon-NULL valid private schema; field descriptors/names must remain live while used.
Returns
One after the custom traversal, even if individual tags failed; zero on structural fetch/bookkeeping failure, with possibly changed state.

Definition at line 6999 of file tif_dirread.c.

References _TIFFCreateAnonField(), _TIFFfreeExt(), _TIFFGetFields(), _TIFFmallocExt(), _TIFFMergeFields(), _TIFFSetupFields(), CalcFinalIFDdatasizeReading(), CheckDirCount(), _TIFFFieldArray::count, EXIFTAG_SUBJECTDISTANCE, FAILED_FII, _TIFFField::field_bit, FIELD_CUSTOM, FIELD_IGNORE, _TIFFField::field_name, _TIFFField::field_readcount, _TIFFField::field_tag, _TIFFField::field_type, _TIFFFieldArray::fields, _TIFFField::set_get_field_type, TIFFDirectory::td_dirdatasize_offsets, TIFFDirectory::td_samplesperpixel, TIFFDirEntry::tdir_ignore, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_dir, tiff::tif_fields, tiff::tif_nfields, tiff::tif_setdirectory_force_absolute, tiff::tif_warn_about_unknown_tags, TIFF_ANY, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, TIFF_SPP, TIFF_VARIABLE, TIFF_VARIABLE2, TIFFDefaultDirectory(), TIFFErrorExtR(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchSubjectDistance(), TIFFFieldIsAnonymous(), TIFFFreeDirectory(), TIFFReadDirectoryCheckOrder(), TIFFReadDirectoryFindFieldInfo(), TIFFWarningExtR(), and TRUE.

Referenced by TIFFReadEXIFDirectory(), and TIFFReadGPSDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadDirectory()

int TIFFReadDirectory ( TIFF *  tif)
extern

Read and install the next image directory.

Reads entries, validates/normalises tags, configures codecs, and computes image geometry. May register unknown fields, estimate missing byte counts, and chop eligible uncompressed strips into logical smaller strips. Does not decode image pixels. Allocates directory-owned values and bookkeeping; seeks/reads or uses mapped bytes and invokes tag/codec/extender/diagnostic callbacks. Replaces old values and codec/schema state without saving dirty contents. Borrowed values and replaceable descriptors can become invalid. Failure has no rollback: offsets/index/flags/schema and some values can already have changed, with the index advanced before later semantic checks. Some optional tag errors are recoverable; success is not proof that every stored tag was retained. There is no general errno contract. With next offset zero, sets the current offset to zero and returns zero without resetting old values or emitting an end-of-chain diagnostic. See Reading and writing IFDs for recovery and ownership limits.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
Returns
One for an installed image directory, zero at chain end or on detected loop, count, validation, allocation, or I/O failure; zero does not preserve old state.

Definition at line 5911 of file tif_dirread.c.

References _TIFFcallocExt(), _TIFFCheckDirNumberAndOffset(), _TIFFCheckFieldIsValidForCodec(), _TIFFCreateAnonField(), _TIFFFillStriles(), _TIFFfreeExt(), _TIFFGetMaxColorChannels(), _TIFFmallocExt(), _TIFFmemcpy(), _TIFFMergeFields(), _TIFFsetShortArrayExt(), ByteCountLooksBad(), CalcFinalIFDdatasizeReading(), ChopUpSingleUncompressedStrip(), COMPRESSION_NONE, COMPRESSION_OJPEG, EstimateStripByteCounts(), EvaluateIFDdatasizeReading(), FAILED_FII, FALSE, _TIFFField::field_bit, FIELD_BITSPERSAMPLE, FIELD_COLORMAP, FIELD_IGNORE, FIELD_IMAGEDIMENSIONS, FIELD_MAXSAMPLEVALUE, _TIFFField::field_name, FIELD_PHOTOMETRIC, FIELD_SAMPLESPERPIXEL, FIELD_STRIPBYTECOUNTS, FIELD_STRIPOFFSETS, FIELD_TILEDIMENSIONS, FILETYPE_PAGE, FILETYPE_REDUCEDIMAGE, isTiled, MissingRequired(), OFILETYPE_PAGE, OFILETYPE_REDUCEDIMAGE, PHOTOMETRIC_MINISBLACK, PHOTOMETRIC_MINISWHITE, PHOTOMETRIC_PALETTE, PHOTOMETRIC_RGB, PHOTOMETRIC_YCBCR, PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, TIFFDirectory::td_bitspersample, TIFFDirectory::td_compression, TIFFDirectory::td_dirdatasize_offsets, TIFFDirectory::td_extrasamples, TIFFDirectory::td_imagedepth, TIFFDirectory::td_imagewidth, TIFFDirectory::td_iswrittentofile, TIFFDirectory::td_maxsamplevalue, TIFFDirectory::td_nstrips, TIFFDirectory::td_photometric, TIFFDirectory::td_planarconfig, TIFFDirectory::td_rowsperstrip, TIFFDirectory::td_sampleinfo, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_scanlinesize, TIFFDirectory::td_stripbytecount_entry, TIFFDirectory::td_stripbytecount_p, TIFFDirectory::td_stripoffset_entry, TIFFDirectory::td_stripoffset_p, TIFFDirectory::td_stripsperimage, TIFFDirectory::td_tiledepth, TIFFDirectory::td_tilelength, TIFFDirectory::td_tilesize, TIFFDirectory::td_tilewidth, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_ignore, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_curdir, tiff::tif_dir, tiff::tif_diroff, tiff::tif_fields, tiff::tif_fixuptags, tiff::tif_flags, tiff::tif_mode, tiff::tif_nextdiroff, tiff::tif_warn_about_unknown_tags, TIFF_ASCII, TIFF_DEFERSTRILELOAD, TIFF_ISTILED, TIFF_LONG, TIFF_LONG8, TIFF_NON_EXISTENT_DIR_NUMBER, TIFF_PERSAMPLE, TIFF_RATIONAL, TIFF_SHORT, TIFF_STRIPCHOP, TIFFDefaultDirectory(), TIFFErrorExtR(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFieldSet, TIFFFieldWithTag(), TIFFFreeDirectory(), TIFFGetStrileByteCount(), TIFFGetStrileOffset(), TIFFNumberOfStrips(), TIFFNumberOfTiles(), TIFFReadDirectoryCheckOrder(), TIFFReadDirectoryFindEntry(), TIFFReadDirectoryFindFieldInfo(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryErrCount, TIFFReadDirEntryErrOk, TIFFReadDirEntryOutputErr(), TIFFReadDirEntryPersampleShort(), TIFFReadDirEntryShort(), TIFFReadDirEntryShortArray(), TIFFScanlineSize(), TIFFSetField(), TIFFSetFieldBit, TIFFSetupStrips(), TIFFStripSize(), TIFFStripSize64(), TIFFTAG_BITSPERSAMPLE, TIFFTAG_COLORMAP, TIFFTAG_COMPRESSION, TIFFTAG_DATATYPE, TIFFTAG_EP_BATTERYLEVEL, TIFFTAG_EXTRASAMPLES, TIFFTAG_IMAGEDEPTH, TIFFTAG_IMAGELENGTH, TIFFTAG_IMAGEWIDTH, TIFFTAG_MAXSAMPLEVALUE, TIFFTAG_MINSAMPLEVALUE, TIFFTAG_OSUBFILETYPE, TIFFTAG_PHOTOMETRIC, TIFFTAG_PLANARCONFIG, TIFFTAG_ROWSPERSTRIP, TIFFTAG_SAMPLEFORMAT, TIFFTAG_SAMPLESPERPIXEL, TIFFTAG_SMAXSAMPLEVALUE, TIFFTAG_SMINSAMPLEVALUE, TIFFTAG_STRIPBYTECOUNTS, TIFFTAG_STRIPOFFSETS, TIFFTAG_SUBFILETYPE, TIFFTAG_TILEBYTECOUNTS, TIFFTAG_TILEDEPTH, TIFFTAG_TILELENGTH, TIFFTAG_TILEOFFSETS, TIFFTAG_TILEWIDTH, TIFFTAG_TRANSFERFUNCTION, TIFFTileSize(), TIFFWarningExtR(), TIFFDirEntry::toff_long8, TRUE, TryChopUpUncompressedBigTiff(), TIFFRational_t::uDenom, and TIFFRational_t::uNum.

Referenced by TIFFClientOpenExt(), TIFFSetDirectory(), and TIFFSetSubDirectory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFReadEXIFDirectory()

int TIFFReadEXIFDirectory ( TIFF *  tif,
toff_t  diroff 
)
extern

Read a EXIF metadata directory.

Delegates to TIFFReadCustomDirectory() with the built-in EXIF schema, including its allocations, callbacks, borrowed-result invalidation, partial-failure rules, and ignored per-tag failures. Obtain the offset from the matching parent pointer tag. Does not decode image data, follow a metadata chain, or preserve the previous directory context.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]diroffNonzero metadata-IFD offset in file bytes.
Returns
One on completed custom traversal (not proof that all tags loaded), zero on detected structural failure; no rollback.

Definition at line 7265 of file tif_dirread.c.

References _TIFFGetExifFields(), and TIFFReadCustomDirectory().

Here is the call graph for this function:

◆ TIFFReadGPSDirectory()

int TIFFReadGPSDirectory ( TIFF *  tif,
toff_t  diroff 
)
extern

Read a EXIF GPS metadata directory.

Delegates to TIFFReadCustomDirectory() with the built-in EXIF GPS schema, including its allocations, callbacks, borrowed-result invalidation, partial-failure rules, and ignored per-tag failures. Obtain the offset from the matching parent pointer tag. Does not decode image data, follow a metadata chain, or preserve the previous directory context.

Parameters
[in,out]tifNon-NULL live handle with matching schema/state; serialise access externally.
[in]diroffNonzero metadata-IFD offset in file bytes.
Returns
One on completed custom traversal (not proof that all tags loaded), zero on detected structural failure; no rollback.

Definition at line 7273 of file tif_dirread.c.

References _TIFFGetGpsFields(), and TIFFReadCustomDirectory().

Here is the call graph for this function: