LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Modules | Functions
Lifecycle

Open, inspect, flush, and release TIFF handles and their I/O resources. More...

Collaboration diagram for Lifecycle:

Modules

 Open options and diagnostic context
 Configure checked allocations and per-handle diagnostics for opening.
 
 Client I/O callbacks
 Define the client-resource operations used by a TIFF handle.
 
 C++ stream interface
 Attach TIFF handles to caller-owned seekable C++ streams.
 

Functions

TIFF * TIFFOpenW (const wchar_t *name, const char *mode)
 Open a TIFF file using a wide Windows pathname.
 
TIFF * TIFFOpenWExt (const wchar_t *name, const char *mode, TIFFOpenOptions *opts)
 Open a TIFF file using a wide Windows pathname.
 
void TIFFCleanup (TIFF *tif)
 Release library state without invoking the client close callback.
 
void TIFFClose (TIFF *tif)
 Release a TIFF handle and invoke its client close callback.
 
int TIFFFlush (TIFF *tif)
 Flush pending image data and dirty directory information.
 
int TIFFFlushData (TIFF *tif)
 Flush pending encoded image data without committing directory changes.
 
int TIFFFileno (TIFF *tif)
 Return the handle's file-descriptor metadata.
 
int TIFFSetFileno (TIFF *tif, int fd)
 Replace descriptor metadata without changing client I/O routing.
 
thandle_t TIFFClientdata (TIFF *tif)
 Return the context passed to client I/O callbacks.
 
thandle_t TIFFSetClientdata (TIFF *tif, thandle_t newvalue)
 Replace the context passed to all client I/O callbacks.
 
int TIFFGetMode (TIFF *tif)
 Return the stored library access mode.
 
int TIFFSetMode (TIFF *tif, int mode)
 Replace the stored library access mode without reopening the resource.
 
int TIFFIsTiled (TIFF *tif)
 Test whether the current image uses tiles.
 
int TIFFIsByteSwapped (TIFF *tif)
 Test whether file values require byte swapping for this host.
 
int TIFFIsUpSampled (TIFF *tif)
 Test whether the active codec supplies upsampled data.
 
int TIFFIsMSB2LSB (TIFF *tif)
 Test the selected data bit-fill-order flag.
 
int TIFFIsBigEndian (TIFF *tif)
 Test whether the stored file signature is TIFF_BIGENDIAN.
 
int TIFFIsBigTIFF (TIFF *tif)
 Test whether the handle uses the BigTIFF format.
 
TIFFReadWriteProc TIFFGetReadProc (TIFF *tif)
 Return the installed client read callback.
 
TIFFReadWriteProc TIFFGetWriteProc (TIFF *tif)
 Return the installed client write callback.
 
TIFFSeekProc TIFFGetSeekProc (TIFF *tif)
 Return the installed client seek callback.
 
TIFFCloseProc TIFFGetCloseProc (TIFF *tif)
 Return the installed client close callback.
 
TIFFSizeProc TIFFGetSizeProc (TIFF *tif)
 Return the installed client file-size callback.
 
TIFFMapFileProc TIFFGetMapFileProc (TIFF *tif)
 Return the installed client mapping callback.
 
TIFFUnmapFileProc TIFFGetUnmapFileProc (TIFF *tif)
 Return the installed client unmapping callback.
 
const char * TIFFFileName (TIFF *tif)
 Return the handle's diagnostic filename.
 
const char * TIFFSetFileName (TIFF *tif, const char *name)
 Replace the diagnostic filename pointer without copying it.
 
TIFF * TIFFOpen (const char *name, const char *mode)
 Open a TIFF file by pathname.
 
TIFF * TIFFOpenExt (const char *name, const char *mode, TIFFOpenOptions *opts)
 Open a TIFF file by pathname.
 
TIFF * TIFFFdOpen (int fd, const char *name, const char *mode)
 Attach a TIFF handle to an already-open platform resource.
 
TIFF * TIFFFdOpenExt (int fd, const char *name, const char *mode, TIFFOpenOptions *opts)
 Attach a TIFF handle to an already-open platform resource.
 
TIFF * TIFFClientOpen (const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc)
 Initialise a TIFF handle using client-supplied I/O callbacks.
 
TIFF * TIFFClientOpenExt (const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, TIFFOpenOptions *opts)
 Initialise a TIFF handle using client-supplied I/O callbacks.
 

Detailed Description

Open, inspect, flush, and release TIFF handles and their I/O resources.

See Lifecycle for ownership, open modes, failure postconditions, and platform/stream adapter limitations.

Function Documentation

◆ TIFFCleanup()

void TIFFCleanup ( TIFF *  tif)
extern

Release library state without invoking the client close callback.

For a writable handle, attempts TIFFFlush() and discards its result. Releases codec/directory state, offset maps, client-info names/nodes, owned buffers and field tables; releases mapped views through the unmapping callback, then frees the handle. Borrowed client-info payloads and diagnostic contexts are not freed.

The client I/O resource and any adapter context normally freed by closeproc remain the caller's responsibility. Save TIFFGetCloseProc() and TIFFClientdata() before cleanup if they are needed afterward. This is especially important for the C++ stream adapter. The handle and all borrowed views into its storage become invalid, even when flushing fails.

There is no status result. Error/warning callbacks may run, including during flushing and cleanup. Call TIFFFlush() first when its status is needed; cleanup is not an all-or-nothing write transaction.

Parameters
[in,out]tifNon-NULL live TIFF handle; invalid after the call.

Definition at line 40 of file tif_close.c.

References _TIFFCleanupIFDOffsetAndNumberMaps(), _TIFFfreeExt(), _TIFFFieldArray::allocated_size, _TIFFField::field_bit, FIELD_CUSTOM, _TIFFField::field_name, _TIFFFieldArray::fields, isMapped, client_info::name, client_info::next, tiff::tif_base, tiff::tif_clientinfo, tiff::tif_cur_cumulated_mem_alloc, tiff::tif_fields, tiff::tif_fieldscompat, tiff::tif_flags, tiff::tif_mode, tiff::tif_nfields, tiff::tif_nfieldscompat, tiff::tif_rawdata, tiff::tif_rawdatasize, tiff::tif_size, TIFF_MYBUFFER, TIFFErrorExtR(), TIFFFieldIsAnonymous(), TIFFFlush(), TIFFFreeDirectory(), and TIFFUnmapFileContents.

Referenced by TIFFClientOpenExt(), and TIFFClose().

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

◆ TIFFClientdata()

thandle_t TIFFClientdata ( TIFF *  tif)
extern

Return the context passed to client I/O callbacks.

Reads stored state without performing I/O, validating the underlying resource, allocating, or emitting diagnostics. Requires a live handle and has no distinct failure result. The context lifetime follows the client- open/close contract; querying it does not extend that lifetime.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The stored opaque context, without ownership transfer.

Definition at line 865 of file tif_open.c.

References tiff::tif_clientdata.

◆ TIFFClientOpen()

TIFF * TIFFClientOpen ( const char *  name,
const char *  mode,
thandle_t  clientdata,
TIFFReadWriteProc  readproc,
TIFFReadWriteProc  writeproc,
TIFFSeekProc  seekproc,
TIFFCloseProc  closeproc,
TIFFSizeProc  sizeproc,
TIFFMapFileProc  mapproc,
TIFFUnmapFileProc  unmapproc 
)
extern

Initialise a TIFF handle using client-supplied I/O callbacks.

Initialises a handle over caller-supplied I/O without opening or truncating the underlying resource. Start with the I/O position at TIFF offset zero. Opening can invoke read/seek/size/map callbacks, read the initial directory, and write a new header for writable modes. A short initial header read in a writable mode can initialise a fresh header; do not expect file-content or position rollback on failure.

Equivalent to TIFFClientOpenExt() with opts = NULL. All five non-mapping callbacks must be supplied. Mapping/unmapping are independently optional, but a successful mapping must have a matching unmapper if its resources require release. The callbacks and their context must remain valid through the last call, including TIFFClose(). The name and mode strings need not remain alive after return.

A successful TIFFClose() path invokes closeproc after releasing library state. TIFFCleanup() alone never invokes closeproc. A NULL return does not invoke closeproc: the caller retains responsibility for the client resource/context, though a mapped view may already have been unmapped during failure cleanup. Error handlers can run before or during initialisation; early per-handle errors can receive a NULL TIFF pointer.

Parameters
[in]nameNon-NULL diagnostic name; copied into the handle.
[in]modeNon-NULL open mode; see Open modes.
[in,out]clientdataOpaque client I/O context; passed unchanged to the callbacks.
[in]readprocNon-NULL read callback, even for a write-only application.
[in]writeprocNon-NULL write callback, even for read-only mode.
[in]seekprocNon-NULL seek callback.
[in]closeprocNon-NULL resource/adapter release callback.
[in]sizeprocNon-NULL file-size callback.
[in]mapprocOptional mapping callback; NULL installs a failing no- op mapper.
[in]unmapprocOptional unmapping callback; NULL installs a no-op unmapper.
Returns
An owned TIFF handle, or NULL on failure. Use TIFFClose() for complete normal cleanup; client resource cleanup after NULL remains the caller's responsibility.

Definition at line 315 of file tif_open.c.

References TIFFClientOpenExt().

Referenced by _tiffStreamOpen().

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

◆ TIFFClientOpenExt()

TIFF * TIFFClientOpenExt ( const char *  name,
const char *  mode,
thandle_t  clientdata,
TIFFReadWriteProc  readproc,
TIFFReadWriteProc  writeproc,
TIFFSeekProc  seekproc,
TIFFCloseProc  closeproc,
TIFFSizeProc  sizeproc,
TIFFMapFileProc  mapproc,
TIFFUnmapFileProc  unmapproc,
TIFFOpenOptions *  opts 
)
extern

Initialise a TIFF handle using client-supplied I/O callbacks.

Initialises a handle over caller-supplied I/O without opening or truncating the underlying resource. Start with the I/O position at TIFF offset zero. Opening can invoke read/seek/size/map callbacks, read the initial directory, and write a new header for writable modes. A short initial header read in a writable mode can initialise a fresh header; do not expect file-content or position rollback on failure.

Copies options but borrows callback context pointers. All five non-mapping callbacks must be supplied. Mapping/unmapping are independently optional, but a successful mapping must have a matching unmapper if its resources require release. The callbacks and their context must remain valid through the last call, including TIFFClose(). The name and mode strings need not remain alive after return.

A successful TIFFClose() path invokes closeproc after releasing library state. TIFFCleanup() alone never invokes closeproc. A NULL return does not invoke closeproc: the caller retains responsibility for the client resource/context, though a mapped view may already have been unmapped during failure cleanup. Error handlers can run before or during initialisation; early per-handle errors can receive a NULL TIFF pointer.

Parameters
[in]nameNon-NULL diagnostic name; copied into the handle.
[in]modeNon-NULL open mode; see Open modes.
[in,out]clientdataOpaque client I/O context; passed unchanged to the callbacks.
[in]readprocNon-NULL read callback, even for a write-only application.
[in]writeprocNon-NULL write callback, even for read-only mode.
[in]seekprocNon-NULL seek callback.
[in]closeprocNon-NULL resource/adapter release callback.
[in]sizeprocNon-NULL file-size callback.
[in]mapprocOptional mapping callback; NULL installs a failing no- op mapper.
[in]unmapprocOptional unmapping callback; NULL installs a no-op unmapper.
[in]optsBorrowed options copied before return, or NULL for defaults.
Returns
An owned TIFF handle, or NULL on failure. Use TIFFClose() for complete normal cleanup; client resource cleanup after NULL remains the caller's responsibility.

Definition at line 326 of file tif_open.c.

References _tiffDummyMapProc(), _tiffDummyUnmapProc(), _TIFFErrorEarly(), _TIFFfreeExt(), _TIFFgetMode(), _TIFFmallocExt(), _TIFFmemcpy(), _TIFFmemset(), _TIFFResetTifDirAndInitStrileCounters(), _TIFFSetDefaultCompressionState(), TIFFHeaderUnion::big, TIFFHeaderUnion::common, TIFFOpenOptions::errorhandler, TIFFOpenOptions::errorhandler_user_data, FALSE, FILLORDER_LSB2MSB, FILLORDER_MSB2LSB, HOST_BIGENDIAN, TIFFOpenOptions::max_cumulated_mem_alloc, TIFFOpenOptions::max_single_mem_alloc, MDI_BIGENDIAN, MDI_LITTLEENDIAN, MDI_SUPPORT, ReadOK, STRIPCHOP_DEFAULT, TIFF_BIGENDIAN, TIFF_BIGTIFF, TIFF_DEFERSTRILELOAD, TIFF_HEADERONLY, TIFF_LAZYSTRILELOAD_ASKED, TIFF_LITTLEENDIAN, TIFF_MAPPED, TIFF_MYBUFFER, TIFF_NON_EXISTENT_DIR_NUMBER, TIFFHeaderBig::tiff_offsetsize, TIFF_STRIPCHOP, TIFF_SWAB, TIFFHeaderCommon::tiff_version, TIFF_VERSION_BIG, TIFF_VERSION_CLASSIC, TIFFCleanup(), TIFFDefaultDirectory(), TIFFErrorExtR(), TIFFMapFileContents, TIFFReadDirectory(), TIFFSeekFile, TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), TIFFWarningExtR(), TIFFOpenOptions::warn_about_unknown_tags, TIFFOpenOptions::warnhandler, TIFFOpenOptions::warnhandler_user_data, and WriteOK.

Referenced by TIFFClientOpen(), TIFFFdOpenExt(), and TIFFFdOpenExt().

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

◆ TIFFClose()

void TIFFClose ( TIFF *  tif)
extern

Release a TIFF handle and invoke its client close callback.

Saves the close callback and client context, calls TIFFCleanup(), then invokes the saved close callback. The handle is already invalid when closeproc runs. Borrowed diagnostic and client-info contexts are not independently freed by the library. A stream adapter releases its own wrapper but leaves the caller's stream open.

There is no status result: flush failures and the close callback's return value are discarded. Error/warning callbacks may run during cleanup, but a close failure need not produce a library diagnostic. Call TIFFFlush() before closing to inspect buffered-write status; that does not certify OS durability or successful resource close. NULL is accepted.

Parameters
[in,out]tifLive TIFF handle to release, or NULL for a no-op.

Definition at line 145 of file tif_close.c.

References tiff::tif_clientdata, tiff::tif_closeproc, and TIFFCleanup().

Here is the call graph for this function:

◆ TIFFFdOpen()

TIFF * TIFFFdOpen ( int  fd,
const char *  name,
const char *  mode 
)
extern

Attach a TIFF handle to an already-open platform resource.

Wraps an existing resource without opening it or physically truncating it. The resource must support seek/read and, for writable modes, write. Initialise its position at the beginning of the TIFF data. Mode w writes a fresh header; truncate the resource yourself if physical truncation is required.

Equivalent to TIFFFdOpenExt(fd, name, mode, NULL). On success TIFFClose() invokes the backend close callback. On a NULL return the resource stays the caller's responsibility; its position and content may already have changed. Diagnostics follow the configured handlers. The POSIX/CRT backend expects a file descriptor; the native Windows backend expects its integer representation of a Windows HANDLE, not a CRT descriptor.

Parameters
[in]fdAlready-open resource in the backend's descriptor convention; see Client I/O and platform conventions.
[in]nameNon-NULL diagnostic name; copied into the new handle.
[in]modeNon-NULL open mode consistent with the resource access permissions.
Returns
An owned TIFF handle, or NULL on failure. Close a successful handle with TIFFClose(); on failure close the resource yourself as appropriate.

Definition at line 351 of file tif_unix.c.

References TIFFFdOpenExt(), and TIFFFdOpenExt().

Here is the call graph for this function:

◆ TIFFFdOpenExt()

TIFF * TIFFFdOpenExt ( int  fd,
const char *  name,
const char *  mode,
TIFFOpenOptions *  opts 
)
extern

Attach a TIFF handle to an already-open platform resource.

Wraps an existing resource without opening it or physically truncating it. The resource must support seek/read and, for writable modes, write. Initialise its position at the beginning of the TIFF data. Mode w writes a fresh header; truncate the resource yourself if physical truncation is required.

Uses the supplied options. On success TIFFClose() invokes the backend close callback. On a NULL return the resource stays the caller's responsibility; its position and content may already have changed. Diagnostics follow the configured handlers. The POSIX/CRT backend expects a file descriptor; the native Windows backend expects its integer representation of a Windows HANDLE, not a CRT descriptor.

Parameters
[in]fdAlready-open resource in the backend's descriptor convention; see Client I/O and platform conventions.
[in]nameNon-NULL diagnostic name; copied into the new handle.
[in]modeNon-NULL open mode consistent with the resource access permissions.
[in]optsBorrowed options copied into the handle, or NULL for defaults.
Returns
An owned TIFF handle, or NULL on failure. Close a successful handle with TIFFClose(); on failure close the resource yourself as appropriate.

Definition at line 356 of file tif_unix.c.

References _tiffCloseProc(), _tiffCloseProc(), _tiffDummyMapProc(), _tiffDummyUnmapProc(), _tiffMapProc(), _tiffMapProc(), _tiffReadProc(), _tiffReadProc(), _tiffSeekProc(), _tiffSeekProc(), _tiffSizeProc(), _tiffSizeProc(), _tiffUnmapProc(), _tiffUnmapProc(), _tiffWriteProc(), _tiffWriteProc(), fd_as_handle_union::fd, fd_as_handle_union::h, thandle_from_int(), tiff::tif_fd, and TIFFClientOpenExt().

Referenced by TIFFFdOpen(), TIFFFdOpen(), TIFFOpenExt(), and TIFFOpenWExt().

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

◆ TIFFFileName()

const char * TIFFFileName ( TIFF *  tif)
extern

Return the handle's diagnostic filename.

Reads stored state without performing I/O, validating the underlying resource, allocating, or emitting diagnostics. Requires a live handle and has no distinct failure result. Do not free or modify the returned string. The initial name survives until handle cleanup; a TIFFSetFileName() replacement has the caller-managed lifetime described there.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
A borrowed filename pointer; initially it refers to the handle's copied name.

Definition at line 835 of file tif_open.c.

References tiff::tif_name.

Referenced by _TIFFReadEncodedStripAndAllocBuffer(), _TIFFReadEncodedTileAndAllocBuffer(), buildMap(), calcCopyToRasterParameter(), checkColOffsetByteAligned(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), makebwmap(), makecmap(), PickContigCase(), setorientation(), setupMap(), TIFFReadRGBAImageOriented(), TIFFReadRGBAStripExt(), TIFFReadRGBATileExt(), and TIFFRGBAImageGet().

Here is the caller graph for this function:

◆ TIFFFileno()

int TIFFFileno ( TIFF *  tif)
extern

Return the handle's file-descriptor metadata.

Reads stored state without performing I/O, validating the underlying resource, allocating, or emitting diagnostics. Requires a live handle and has no distinct failure result. Client I/O uses TIFFClientdata(), not this metadata. A generic TIFFClientOpen() handle starts with descriptor metadata zero unless changed.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The stored descriptor metadata, not a separately acquired resource.

Definition at line 850 of file tif_open.c.

References tiff::tif_fd.

◆ TIFFFlush()

int TIFFFlush ( TIFF *  tif)
extern

Flush pending image data and dirty directory information.

Runs codec postencoding and buffered writes as needed, then updates dirty directory or strip/tile-array information. May change file position, contents, and directory/buffer state and invoke I/O or diagnostic callbacks. A failure can leave partial file writes and changed state; no rollback is provided. Does not close the handle, call fsync(), or flush a caller-owned C++ stream to its final device. Ownership and handle lifetime are unchanged.

Parameters
[in,out]tifNon-NULL live TIFF handle.
Returns
1 on success, including a read-only/no-work case; 0 if flushing image data or rewriting directory information fails. In update mode, a failed strile-array-only rewrite falls back to a full directory rewrite; its diagnostics can occur even when 1 is returned.

Definition at line 35 of file tif_flush.c.

References tiff::tif_flags, tiff::tif_mode, TIFF_DIRTYDIRECT, TIFF_DIRTYSTRIP, TIFFFlushData(), TIFFForceStrileArrayWriting(), and TIFFRewriteDirectory().

Referenced by TIFFCleanup().

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

◆ TIFFFlushData()

int TIFFFlushData ( TIFF *  tif)
extern

Flush pending encoded image data without committing directory changes.

Finalises pending codec output and writes buffered image data. It does not by itself commit dirty directory metadata; use TIFFFlush() for that. May invoke codec, I/O, and diagnostic callbacks and alter file position, contents, and buffer flags. In particular the pending-postencode flag is cleared before the postencode callback, even if that callback fails, so failure is not a rollback/retry guarantee. Does not close or release the handle and does not ensure device durability.

Parameters
[in,out]tifNon-NULL live TIFF handle.
Returns
1 when no writing is pending or the data flush succeeds; 0 on postencode or write failure.

Definition at line 151 of file tif_flush.c.

References tiff::tif_flags, tiff::tif_postencode, TIFF_BEENWRITING, TIFF_POSTENCODE, and TIFFFlushData1().

Referenced by TIFFCheckRead(), TIFFFlush(), and TIFFWriteScanline().

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

◆ TIFFGetCloseProc()

TIFFCloseProc TIFFGetCloseProc ( TIFF *  tif)
extern

Return the installed client close callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is the non-NULL callback supplied at open.

Definition at line 964 of file tif_open.c.

References tiff::tif_closeproc.

◆ TIFFGetMapFileProc()

TIFFMapFileProc TIFFGetMapFileProc ( TIFF *  tif)
extern

Return the installed client mapping callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is non-NULL: the client's callback, or a dummy that always reports failure when none was supplied at open.

Definition at line 974 of file tif_open.c.

References tiff::tif_mapproc.

◆ TIFFGetMode()

int TIFFGetMode ( TIFF *  tif)
extern

Return the stored library access mode.

Reads stored state without performing I/O, validating the underlying resource, allocating, or emitting diagnostics. Requires a live handle and has no distinct failure result. Changing OS access permissions or stream state outside the library is not reflected by this query.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The stored O_RDONLY/O_RDWR-style mode value, not the original mode string.

Definition at line 880 of file tif_open.c.

References tiff::tif_mode.

◆ TIFFGetReadProc()

TIFFReadWriteProc TIFFGetReadProc ( TIFF *  tif)
extern

Return the installed client read callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is the non-NULL callback supplied at open.

Definition at line 949 of file tif_open.c.

References tiff::tif_readproc.

◆ TIFFGetSeekProc()

TIFFSeekProc TIFFGetSeekProc ( TIFF *  tif)
extern

Return the installed client seek callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is the non-NULL callback supplied at open.

Definition at line 959 of file tif_open.c.

References tiff::tif_seekproc.

◆ TIFFGetSizeProc()

TIFFSizeProc TIFFGetSizeProc ( TIFF *  tif)
extern

Return the installed client file-size callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is the non-NULL callback supplied at open.

Definition at line 969 of file tif_open.c.

References tiff::tif_sizeproc.

◆ TIFFGetUnmapFileProc()

TIFFUnmapFileProc TIFFGetUnmapFileProc ( TIFF *  tif)
extern

Return the installed client unmapping callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is non-NULL: the client's callback, or a dummy that does nothing when none was supplied at open.

Definition at line 979 of file tif_open.c.

References tiff::tif_unmapproc.

◆ TIFFGetWriteProc()

TIFFReadWriteProc TIFFGetWriteProc ( TIFF *  tif)
extern

Return the installed client write callback.

Reads the callback pointer without I/O, allocation, mutation, or diagnostics. The pointer alone does not retain the client context or backing code. Invoking it manually requires the matching live TIFFClientdata() context and its callback contract; closing a resource manually while the handle still uses it can invalidate the handle.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
The installed function pointer; no ownership is transferred. For a successfully opened handle it is the non-NULL callback supplied at open.

Definition at line 954 of file tif_open.c.

References tiff::tif_writeproc.

◆ TIFFIsBigEndian()

int TIFFIsBigEndian ( TIFF *  tif)
extern

Test whether the stored file signature is TIFF_BIGENDIAN.

Reads stored header/flag state without I/O, mutation, allocation, or diagnostic callbacks. There is no distinct error result. Directory- and codec-dependent flags describe the current handle state rather than every image in a multipage file.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
Nonzero for TIFF_BIGENDIAN; zero otherwise. The test does not classify MDI signatures as TIFF_BIGENDIAN.

Definition at line 936 of file tif_open.c.

References TIFFHeaderUnion::common, tiff::tif_header, TIFF_BIGENDIAN, and TIFFHeaderCommon::tiff_magic.

◆ TIFFIsBigTIFF()

int TIFFIsBigTIFF ( TIFF *  tif)
extern

Test whether the handle uses the BigTIFF format.

Reads stored header/flag state without I/O, mutation, allocation, or diagnostic callbacks. There is no distinct error result. Directory- and codec-dependent flags describe the current handle state rather than every image in a multipage file.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
Nonzero for BigTIFF; zero for classic TIFF.

Definition at line 944 of file tif_open.c.

References tiff::tif_flags, and TIFF_BIGTIFF.

◆ TIFFIsByteSwapped()

int TIFFIsByteSwapped ( TIFF *  tif)
extern

Test whether file values require byte swapping for this host.

Reads stored header/flag state without I/O, mutation, allocation, or diagnostic callbacks. There is no distinct error result. Directory- and codec-dependent flags describe the current handle state rather than every image in a multipage file.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
Nonzero if the byte-swapping flag is set; zero otherwise.

Definition at line 921 of file tif_open.c.

References tiff::tif_flags, and TIFF_SWAB.

◆ TIFFIsMSB2LSB()

int TIFFIsMSB2LSB ( TIFF *  tif)
extern

Test the selected data bit-fill-order flag.

Reads stored header/flag state without I/O, mutation, allocation, or diagnostic callbacks. There is no distinct error result. Directory- and codec-dependent flags describe the current handle state rather than every image in a multipage file.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
Nonzero for MSB-to-LSB data order; zero otherwise. This is not a CPU byte-order test.

Definition at line 931 of file tif_open.c.

References FILLORDER_MSB2LSB, and isFillOrder.

◆ TIFFIsTiled()

int TIFFIsTiled ( TIFF *  tif)
extern

Test whether the current image uses tiles.

Reads stored header/flag state without I/O, mutation, allocation, or diagnostic callbacks. There is no distinct error result. Directory- and codec-dependent flags describe the current handle state rather than every image in a multipage file.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
Nonzero for tiled storage; zero for strip storage.

Definition at line 896 of file tif_open.c.

References isTiled.

Referenced by PickContigCase(), PickSeparateCase(), TIFFForceStrileArrayWriting(), TIFFReadFromUserBuffer(), TIFFReadRGBAStripExt(), and TIFFReadRGBATileExt().

Here is the caller graph for this function:

◆ TIFFIsUpSampled()

int TIFFIsUpSampled ( TIFF *  tif)
extern

Test whether the active codec supplies upsampled data.

Reads stored header/flag state without I/O, mutation, allocation, or diagnostic callbacks. There is no distinct error result. Directory- and codec-dependent flags describe the current handle state rather than every image in a multipage file.

Parameters
[in]tifNon-NULL live TIFF handle.
Returns
Nonzero if the upsampled-output flag is set; zero otherwise.

Definition at line 926 of file tif_open.c.

References isUpSampled.

◆ TIFFOpen()

TIFF * TIFFOpen ( const char *  name,
const char *  mode 
)
extern

Open a TIFF file by pathname.

Opens the OS resource, then initialises a TIFF handle. Pathname mode w truncates an existing file, a may create one, and r/r+ require an existing resource. Opening may read a directory, map the file, or write a header; failures do not roll back file changes.

Equivalent to TIFFOpenExt(name, mode, NULL). Reports ordinary opening/initialisation failures through the configured error handlers. errno/GetLastError may reflect a platform failure but are not a complete library-error channel. See Lifecycle for mode and lifetime details.

Parameters
[in]nameNon-NULL, null-terminated pathname interpreted by the selected platform backend.
[in]modeNon-NULL, null-terminated open mode; see Open modes.
Returns
An owned TIFF handle to release with TIFFClose(), or NULL on failure. On normal failure paths the internally opened resource is closed.

Definition at line 374 of file tif_unix.c.

References TIFFOpenExt().

Here is the call graph for this function:

◆ TIFFOpenExt()

TIFF * TIFFOpenExt ( const char *  name,
const char *  mode,
TIFFOpenOptions *  opts 
)
extern

Open a TIFF file by pathname.

Opens the OS resource, then initialises a TIFF handle. Pathname mode w truncates an existing file, a may create one, and r/r+ require an existing resource. Opening may read a directory, map the file, or write a header; failures do not roll back file changes.

Uses the supplied options. Diagnostic callbacks may run before a handle exists; per-handle callback contexts remain borrowed through close. Reports ordinary opening/initialisation failures through the configured error handlers. errno/GetLastError may reflect a platform failure but are not a complete library-error channel. See Lifecycle for mode and lifetime details.

Parameters
[in]nameNon-NULL, null-terminated pathname interpreted by the selected platform backend.
[in]modeNon-NULL, null-terminated open mode; see Open modes.
[in]optsBorrowed open options, or NULL for defaults; copied before return.
Returns
An owned TIFF handle to release with TIFFClose(), or NULL on failure. On normal failure paths the internally opened resource is closed.

Definition at line 379 of file tif_unix.c.

References _TIFFErrorEarly(), _TIFFgetMode(), thandle_to_int(), TIFFFdOpenExt(), and TIFFFdOpenExt().

Referenced by TIFFOpen().

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

◆ TIFFOpenW()

TIFF * TIFFOpenW ( const wchar_t *  name,
const char *  mode 
)

Open a TIFF file using a wide Windows pathname.

Opens the OS resource, then initialises a TIFF handle. Pathname mode w truncates an existing file, a may create one, and r/r+ require an existing resource. Opening may read a directory, map the file, or write a header; failures do not roll back file changes.

Equivalent to TIFFOpenWExt(name, mode, NULL). Reports ordinary opening/initialisation failures through the configured error handlers. errno/GetLastError may reflect a platform failure but are not a complete library-error channel. See Lifecycle for mode and lifetime details.

Available only on Windows. The original wide pathname opens the resource; an ANSI-code-page conversion is used for the diagnostic name, falling back to "<unknown>" if conversion sizing fails. The current filename-conversion allocation-failure path returns NULL without closing the just-opened OS resource; this implementation limitation is recorded in Current implementation limits.

Parameters
[in]nameNon-NULL, null-terminated Windows wide-character pathname.
[in]modeNon-NULL, null-terminated open mode; see Open modes.
Returns
An owned TIFF handle to release with TIFFClose(), or NULL on failure. On normal failure paths the internally opened resource is closed. The conversion-allocation failure exception to resource cleanup is described above.

Definition at line 458 of file tif_win32.c.

References TIFFOpenWExt().

Here is the call graph for this function:

◆ TIFFOpenWExt()

TIFF * TIFFOpenWExt ( const wchar_t *  name,
const char *  mode,
TIFFOpenOptions *  opts 
)

Open a TIFF file using a wide Windows pathname.

Opens the OS resource, then initialises a TIFF handle. Pathname mode w truncates an existing file, a may create one, and r/r+ require an existing resource. Opening may read a directory, map the file, or write a header; failures do not roll back file changes.

Uses the supplied options. Diagnostic callbacks may run before a handle exists; per-handle callback contexts remain borrowed through close. Reports ordinary opening/initialisation failures through the configured error handlers. errno/GetLastError may reflect a platform failure but are not a complete library-error channel. See Lifecycle for mode and lifetime details.

Available only on Windows. The original wide pathname opens the resource; an ANSI-code-page conversion is used for the diagnostic name, falling back to "<unknown>" if conversion sizing fails. The current filename-conversion allocation-failure path returns NULL without closing the just-opened OS resource; this implementation limitation is recorded in Current implementation limits.

Parameters
[in]nameNon-NULL, null-terminated Windows wide-character pathname.
[in]modeNon-NULL, null-terminated open mode; see Open modes.
[in]optsBorrowed open options, or NULL for defaults; copied before return.
Returns
An owned TIFF handle to release with TIFFClose(), or NULL on failure. On normal failure paths the internally opened resource is closed. The conversion-allocation failure exception to resource cleanup is described above.

Definition at line 497 of file tif_win32.c.

References _TIFFErrorEarly(), _TIFFfree(), _TIFFgetMode(), _TIFFmalloc(), thandle_to_int(), and TIFFFdOpenExt().

Referenced by TIFFOpenW().

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

◆ TIFFSetClientdata()

thandle_t TIFFSetClientdata ( TIFF *  tif,
thandle_t  newvalue 
)
extern

Replace the context passed to all client I/O callbacks.

Stores the new context without retaining, validating, or releasing either value. Subsequent callbacks, including unmapping and closing, receive the replacement. The caller must preserve compatibility with installed callbacks and existing buffers/mappings; replacing the context does not reset those. Descriptor metadata is unchanged. No diagnostic or distinct failure result occurs.

Parameters
[in,out]tifNon-NULL live TIFF handle.
[in]newvalueReplacement context compatible with all installed callbacks.
Returns
The previous context, without ownership transfer.

Definition at line 870 of file tif_open.c.

References tiff::tif_clientdata.

◆ TIFFSetFileName()

const char * TIFFSetFileName ( TIFF *  tif,
const char *  name 
)
extern

Replace the diagnostic filename pointer without copying it.

Stores the supplied pointer without allocation, validation, or I/O. The new null-terminated name must remain valid until replaced again or the handle is released. Does not rename the OS resource. An original inline name remains valid until handle cleanup; the lifetime of a previous caller-supplied name remains the caller's responsibility. No diagnostics or distinct failure result occur.

Parameters
[in,out]tifNon-NULL live TIFF handle.
[in]nameNon-NULL borrowed null-terminated diagnostic name.
Returns
The previous borrowed filename pointer; it is not freed by this call.

Definition at line 840 of file tif_open.c.

References tiff::tif_name.

◆ TIFFSetFileno()

int TIFFSetFileno ( TIFF *  tif,
int  fd 
)
extern

Replace descriptor metadata without changing client I/O routing.

Stores fd without opening, closing, duplicating, or validating any resource. Does not change TIFFClientdata() or callbacks; I/O continues through the existing client context. No diagnostics or distinct failure result occur.

Parameters
[in,out]tifNon-NULL live TIFF handle.
[in]fdReplacement descriptor metadata.
Returns
The previous descriptor metadata.

Definition at line 855 of file tif_open.c.

References tiff::tif_fd.

◆ TIFFSetMode()

int TIFFSetMode ( TIFF *  tif,
int  mode 
)
extern

Replace the stored library access mode without reopening the resource.

Stores the integer without validation or changing OS permissions. Can alter library read/write/flush decisions; the caller must ensure compatibility with the actual resource and handle state. Does not close, reopen, or otherwise take ownership of a resource. No diagnostic or distinct failure result occurs.

Parameters
[in,out]tifNon-NULL live TIFF handle.
[in]modeReplacement O_RDONLY/O_RDWR-style mode value.
Returns
The previous stored access mode.

Definition at line 885 of file tif_open.c.

References tiff::tif_mode.