### Build and Install Workflow Source: https://libtiff.gitlab.io/libtiff/_sources/build.rst.txt Standard sequence of commands to configure, build, test, and install the software from source. ```shell % cd ./tiff-4.0.5 % ./configure ...lots of messages... % make ...lots of messages... % make check ...lots of messages... # make install ``` ```shell % gzip -dc tiff-4.0.5.tar.gz | tar -xf - % cd ./tiff-4.0.5 % ./configure % make % make check % make install ``` ```shell % gzip -dc tiff-4.0.5.tar.gz | tar -xf - % mkdir tiff-4.0.5-build % cd ./tiff-4.0.5-build % ../tiff-4.0.5/configure % make % make check % make install ``` -------------------------------- ### Write EXIF Directory Pointer Source: https://libtiff.gitlab.io/libtiff/functions/TIFFCustomDirectory.html Example of returning to the first directory and linking an EXIF directory offset. ```c /* Go back to the first directory, and add the EXIFIFD pointer. */ TIFFSetDirectory(tif, 0); TIFFSetField(tif, TIFFTAG_EXIFIFD, pdiroff); ``` -------------------------------- ### Initialize Tiled Image Read Source: https://libtiff.gitlab.io/libtiff/_sources/libtiff.rst.txt Setup variables for reading a tiled TIFF image. ```c main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { uint32_t imageWidth, imageLength; uint32_t tileWidth, tileLength; uint32_t x, y; void *buf; ``` -------------------------------- ### Example Usage of TIFFOpenOptions Source: https://libtiff.gitlab.io/libtiff/functions/TIFFOpenOptions.html Demonstrates allocating TIFFOpenOptions, setting memory limits and a custom error handler, opening a TIFF file with extended options, and then freeing the options. This example requires a custom error handler function `myErrorHandler`. ```c #include "tiffio.h" typedef struct MyErrorHandlerUserDataStruct { /* ... any user data structure ... */ } MyErrorHandlerUserDataStruct; static int myErrorHandler(TIFF *tiff, void *user_data, const char *module, const char *fmt, va_list ap) { MyErrorHandlerUserDataStruct *errorhandler_user_data = (MyErrorHandlerUserDataStruct *)user_data; /*... code of myErrorHandler ...*/ return 1; } main() { tmsize_t limit = (256 * 1024 * 1024); MyErrorHandlerUserDataStruct user_data = { /* ... any data ... */}; TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); TIFFOpenOptionsSetMaxSingleMemAlloc(opts, limit); TIFFOpenOptionsSetErrorHandlerExtR(opts, myErrorHandler, &user_data); TIFF *tif = TIFFOpenExt("foo.tif", "r", opts); TIFFOpenOptionsFree(opts); /* ... go on here ... */ TIFFClose(tif); } ``` -------------------------------- ### Initialize and Use YCbCr to RGB Conversion Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFcolor.rst.txt Example demonstrating memory allocation, initialization, and conversion loop for YCbCr to RGB. ```c float *luma, *refBlackWhite; uint16_t hs, vs; /* Initialize structures */ TIFFYCbCrToRGB *ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB), sizeof(long)) + 4*256*sizeof(TIFFRGBValue) + 2*256*sizeof(int) + 3*256*sizeof(int32_t)); if (ycbcr == NULL) { TIFFError("YCbCr->RGB", "No space for YCbCr->RGB conversion state"); exit(0); } TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE, &refBlackWhite); if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < 0) { exit(0); } /* Start conversion */ uint32_t r, g, b; uint32_t Y; int32_t Cb, Cr; for each pixel in image { TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g, &b); } /* Free state structure */ _TIFFfree(ycbcr); ``` -------------------------------- ### Basic Build Process with Autoconf Source: https://libtiff.gitlab.io/libtiff/build.html Standard procedure for building libtiff on a UNIX system. Requires running configure, make, and make install. ```bash % cd ./tiff-4.0.5 % ./configure ...lots of messages... % make ...lots of messages... % make check ...lots of messages... # make install ``` -------------------------------- ### Build with Ninja Generator Source: https://libtiff.gitlab.io/libtiff/_sources/build.rst.txt Configures the build to use the Ninja build system, a fast alternative to Make. Includes commands for building and installing. ```shell cmake -G Ninja cmake --build . ctest -V cmake --build . --target install ``` -------------------------------- ### Custom Raster Put Method Example Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFRGBAImage.rst.txt Example of overriding TIFFRGBAImage put methods to store raster data in a custom format, shown with simultaneous display logic. ```c static void putContigAndDraw(TIFFRGBAImage* img, uint32_t* raster, uint32_t x, uint32_t y, uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, unsigned char* cp) { (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp); if (x+w == width) { w = width; if (img->orientation == ORIENTATION_TOPLEFT) ``` -------------------------------- ### Verify LibTIFF installation with tiffcp and tiffcmp Source: https://libtiff.gitlab.io/libtiff/_sources/build.rst.txt Use these commands to perform a basic check of the library by compressing an image and verifying the output against the original. ```shell tiffcp -lzw cramps.tif x.tif tiffcmp cramps.tif x.tif ``` -------------------------------- ### Configuring TIFFOpenOptions with Custom Error Handler Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFOpenOptions.rst.txt Example demonstrating the allocation of TIFFOpenOptions, setting memory limits, and registering a custom re-entrant error handler with user data. ```c #include "tiffio.h" typedef struct MyErrorHandlerUserDataStruct { /* ... any user data structure ... */ } MyErrorHandlerUserDataStruct; static int myErrorHandler(TIFF *tiff, void *user_data, const char *module, const char *fmt, va_list ap) { MyErrorHandlerUserDataStruct *errorhandler_user_data = (MyErrorHandlerUserDataStruct *)user_data; /*... code of myErrorHandler ...*/ return 1; } main() { tmsize_t limit = (256 * 1024 * 1024); MyErrorHandlerUserDataStruct user_data = { /* ... any data ... */}; TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); TIFFOpenOptionsSetMaxSingleMemAlloc(opts, limit); TIFFOpenOptionsSetErrorHandlerExtR(opts, myErrorHandler, &user_data); TIFF *tif = TIFFOpenExt("foo.tif", "r", opts); TIFFOpenOptionsFree(opts); /* ... go on here ... */ TIFFClose(tif); } ``` -------------------------------- ### sRGB Display Device Parameters Source: https://libtiff.gitlab.io/libtiff/functions/TIFFcolor.html Example parameters for the sRGB display device, including XYZ to luminance matrix, light output, pixel values, and gamma. ```c TIFFDisplay display_sRGB = { { /* XYZ -> luminance matrix */ { 3.2410F, -1.5374F, -0.4986F }, { -0.9692F, 1.8760F, 0.0416F }, { 0.0556F, -0.2040F, 1.0570F } }, 100.0F, 100.0F, 100.0F, /* Light o/p for reference white */ 255, 255, 255, /* Pixel values for ref. white */ 1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel */ 2.4F, 2.4F, 2.4F, /* Gamma values for the three guns */ }; ``` -------------------------------- ### Read Multi-Page and SubIFD TIFF Source: https://libtiff.gitlab.io/libtiff/_sources/multi_page.rst.txt This example shows how to read multi-page TIFF files and SubIFDs. It iterates through directories, checks for SubIFDs, and navigates the SubIFD chain. The TIFF file must be opened in read mode. ```c /* Reading of multi-page and SubIFD images (subfiles) */ if (!(tiff = TIFFOpen(filename, "r"))) return 1; tdir_t currentDirNumber = TIFFCurrentDirectory(tiff); /* The first directory is already read through TIFFOpen() */ int blnRead = 0; do { /*Check if there are SubIFD subfiles */ void *ptr; if (TIFFGetField(tiff, TIFFTAG_SUBIFD, &number_of_sub_IFDs, &ptr)) { /* Copy SubIFD array from pointer */ memcpy(sub_IFDs_offsets, ptr, number_of_sub_IFDs * sizeof(sub_IFDs_offsets[0])); for (int i = 0; i < number_of_sub_IFDs; i++) { /* Read first SubIFD directory */ if (!TIFFSetSubDirectory(tiff, sub_IFDs_offsets[i])) return 1; /* Check if there is a SubIFD chain behind the first one from * the array, as specified by Adobe */ while (TIFFReadDirectory(tiff)) /* analyse subfile */ ; } /* Go back to main-IFD chain and re-read that main-IFD directory */ if (!TIFFSetDirectory(tiff, currentDirNumber)) return 1; } /* Read next main-IFD directory (subfile) */ blnRead = TIFFReadDirectory(tiff); currentDirNumber = TIFFCurrentDirectory(tiff); } while (blnRead); TIFFClose(tiff); ``` -------------------------------- ### Codec Entry Points for libtiff Source: https://libtiff.gitlab.io/libtiff/internals.html Defines the standard function signatures for various entry points of a custom compression codec within libtiff. These functions handle initialization, setup, decoding, encoding, and cleanup operations. ```c TIFFInitfoo(tif, scheme) /* initialize scheme and setup entry points in tif */ fooSetupDecode(tif) /* called once per IFD after tags has been frozen */ fooPreDecode(tif, sample) /* called once per strip/tile, after data is read, but before the first row is decoded */ fooDecode*(tif, bp, cc, sample) /* decode cc bytes of data into the buffer */ fooDecodeRow(...) fooDecodeStrip(...) fooDecodeTile(...) fooSetupEncode(tif) /* called once per IFD after tags has been frozen */ fooPreEncode(tif, sample) /* called once per strip/tile, before the first row in a strip/tile is encoded */ fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */ fooEncodeRow(...) fooEncodeStrip(...) fooEncodeTile(...) fooPostEncode(tif) /* called once per strip/tile, just before data is written */ fooSeek(tif, row) /* seek forwards row scanlines from the beginning of a strip (row will always be <0 and >rows/strip */ fooCleanup(tif) /* called when compression scheme is replaced by user ``` -------------------------------- ### TIFFFlushData1() Usage Example Source: https://libtiff.gitlab.io/libtiff/internals.html Encoding routines must be aware of the raw data buffer size and call TIFFFlushData1() when necessary to ensure data is written. Pending data is automatically flushed when a new strip/tile starts. ```c TIFFFlushData1() ``` -------------------------------- ### Create and configure custom directory Source: https://libtiff.gitlab.io/libtiff/functions/TIFFCustomDirectory.html Initialize a custom directory and set its specific fields. ```c TIFFCreateCustomDirectory(tiffOut, infoarray); /* for a real custom directory */ /* or alternatively, use GPS or EXIF with pre-defined TIFFFieldArray IFD field structure */ TIFFCreateGPSDirectory(tiffOut); TIFFSetField(tiffOut, GPSTAG_VERSIONID, gpsVersion); /* set fields of the custom directory */ ``` -------------------------------- ### Get Field from TIFF File Source: https://libtiff.gitlab.io/libtiff/functions/TIFFGetField.html Retrieves a field value from a TIFF file using its tag. Use this function to get specific metadata from a TIFF image. ```c int TIFFGetField(TIFF *tif, uint32_t tag, ...) ``` -------------------------------- ### Build with Visual Studio (Win64 Release) Source: https://libtiff.gitlab.io/libtiff/_sources/build.rst.txt Configures the build for a 64-bit Release build using Visual Studio 2013. Includes commands for building and testing. ```shell cmake -G "Visual Studio 12 2013 Win64" cmake --build . --config Release ctest -V -C Release cmake --build . --config Release --target install ``` -------------------------------- ### Field and Data Handling Functions Source: https://libtiff.gitlab.io/libtiff/_sources/functions/libtiff.rst.txt Functions for getting, setting, and clearing fields, and handling TIFF warnings. ```APIDOC ## TIFFUnsetField ### Description Clears the contents of the field in the internal structure. ### Method N/A (Function Signature) ### Endpoint N/A ## TIFFVGetField ### Description Returns the tag value in the current directory. ### Method N/A (Function Signature) ### Endpoint N/A ## TIFFVGetFieldDefaulted ### Description Returns the tag value in the current directory. ### Method N/A (Function Signature) ### Endpoint N/A ## TIFFVSetField ### Description Sets a tag's value in the current directory. ### Method N/A (Function Signature) ### Endpoint N/A ## TIFFWarning ### Description Library-wide warning handling function printing to ``stderr``. ### Method N/A (Function Signature) ### Endpoint N/A ## TIFFWarningExt ### Description User-specific library-wide warning handling function that can be passed a file handle, which is set to the open TIFF file within ``libtiff``. ### Method N/A (Function Signature) ### Endpoint N/A ## TIFFWarningExtR ### Description User-specific re-entrant library warning handling function, to which its TIFF structure is passed containing the pointer to a user-specific data object. ### Method N/A (Function Signature) ### Endpoint N/A ``` -------------------------------- ### TIFFCIELabToRGBInit Source: https://libtiff.gitlab.io/libtiff/functions/TIFFcolor.html Initializes the CIE L*a*b* 1976 to RGB conversion state using a display device description. ```APIDOC ## TIFFCIELabToRGBInit ### Description Initializes the conversion state for CIE L*a*b* 1976 to RGB color space transformation. This requires a TIFFDisplay structure defining the characteristics of the display device. ### Parameters - **display** (TIFFDisplay) - Required - Structure containing the XYZ to luminance matrix, reference white light output, and gamma values. ``` -------------------------------- ### TIFFClientdata - Get client data handle Source: https://libtiff.gitlab.io/libtiff/functions/TIFFOpen.html Retrieves the client data handle associated with an open TIFF file. ```APIDOC ## TIFFClientdata ### Description Returns the client data handle, which is the I/O descriptor used by `libtiff` for the open file. ### Method `client_data_t TIFFClientdata(TIFF *tif)` ### Parameters #### Path Parameters - **tif** (TIFF*) - Required - Handle to the TIFF structure. ### Request Example ```c client_data_t data = TIFFClientdata(tif); ``` ### Response #### Success Response (200) - **data** (client_data_t) - The client data handle. #### Response Example ```c // data is the client data handle ``` ``` -------------------------------- ### TIFFSizeProc Type Source: https://libtiff.gitlab.io/libtiff/functions/TIFFOpen.html Defines the function pointer type for getting the size of a TIFF file. Used with client-opened TIFFs. ```c typedef toff_t (*TIFFSizeProc)(thandle_t) ``` -------------------------------- ### Incorrect Scanline Read Order Source: https://libtiff.gitlab.io/libtiff/_sources/libtiff.rst.txt An example of an incorrect loop order for PLANARCONFIG_SEPARATE that causes issues with compressed strips. ```c for (row = 0; row < imagelength; row++) for (s = 0; s < nsamples; s++) TIFFReadScanline(tif, buf, row, s); ``` -------------------------------- ### Initialize and Convert CIE L*a*b* to RGB Source: https://libtiff.gitlab.io/libtiff/functions/TIFFcolor.html This code initializes the CIE L*a*b* to RGB conversion state, performs the conversion for each pixel using CIE XYZ as an intermediate, and then frees the state structure. Ensure proper initialization of the 'cielab' structure and handle potential errors during initialization. ```c float *whitePoint; float refWhite[3]; /* Initialize structures */ cielab = (TIFFCIELabToRGB *) \ _TIFFmalloc(sizeof(TIFFCIELabToRGB)); if (!cielab) { TIFFError("CIE L*a*b*->RGB", "No space for CIE L*a*b*->RGB conversion state."); exit(0); } TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT, &whitePoint); refWhite[1] = 100.0F; refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1]; refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1]) / whitePoint[1] * refWhite[1]; if (TIFFCIELabToRGBInit(cielab, &display_sRGB, refWhite) < 0) { TIFFError("CIE L*a*b*->RGB", "Failed to initialize CIE L*a*b*->RGB conversion state."); _TIFFfree(cielab); exit(0); } /* Now we can start to convert */ uint32_t r, g, b; uint32_t L; int32_t a, b; float X, Y, Z; for each pixel in image { TIFFCIELabToXYZ(cielab, L, a, b, &X, &Y, &Z); TIFFXYZToRGB(cielab, X, Y, Z, &r, &g, &b); } /* Don't forget to free the state structure */ _TIFFfree(cielab); ``` -------------------------------- ### Basic CMake Build on UNIX Source: https://libtiff.gitlab.io/libtiff/_sources/build.rst.txt Standard procedure for configuring and building the TIFF software on a UNIX-like system using CMake and Make. ```shell $ cd ./tiff-4.0.5 $ cmake ...lots of messages... $ make ...lots of messages... $ make test ...lots of messages... # make install ``` -------------------------------- ### Read TIFF Scanlines Source: https://libtiff.gitlab.io/libtiff/_sources/libtiff.rst.txt Provides examples for reading scanline-organized TIFF files, including handling planar configurations. ```c #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { uint32_t imagelength; void *buf; uint32_t row; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); buf = _TIFFmalloc(TIFFScanlineSize(tif)); for (row = 0; row < imagelength; row++) TIFFReadScanline(tif, buf, row, 0); _TIFFfree(buf); TIFFClose(tif); } } ``` ```c #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { uint32_t imagelength; void *buf; uint32_t row; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); buf = _TIFFmalloc(TIFFScanlineSize(tif)); ``` -------------------------------- ### TIFFReadBufferSetup and TIFFWriteBufferSetup Source: https://libtiff.gitlab.io/libtiff/functions/TIFFbuffer.html These routines allow client-control of the I/O buffers used by the library for reading and writing raw (encoded) data. They are useful for optimizing memory usage and eliminating potential copy operations. ```APIDOC ## TIFFReadBufferSetup and TIFFWriteBufferSetup ### Description The `TIFFReadBufferSetup()` and `TIFFWriteBufferSetup()` routines provide client-control over the I/O buffers used by the LibTIFF library. These functions are primarily for advanced users who wish to optimize memory usage or avoid data copying when working with uncompressed images. `TIFFReadBufferSetup()` configures the buffer for reading raw (encoded) data from a file. If `NULL` is provided for the buffer, the library allocates an appropriately sized buffer. Otherwise, the caller must ensure the provided buffer is sufficiently large for any individual strip of raw data. `TIFFWriteBufferSetup()` configures the buffer for writing raw (encoded) data to a file. If the `size` parameter is -1, the library selects a buffer size sufficient for a complete tile or strip, or at least 8 kilobytes, whichever is larger. If `NULL` is provided for the buffer, the library dynamically allocates a buffer of the appropriate size. ### Synopsis ```c #include int TIFFReadBufferSetup(TIFF *tif, void *buffer, tmsize_t size); int TIFFWriteBufferSetup(TIFF *tif, void *buffer, tmsize_t size); ``` ### Parameters #### TIFFReadBufferSetup - **tif** (TIFF *) - Required - Handle to the TIFF file. - **buffer** (void *) - Required/Optional - Pointer to the buffer to use. If NULL, the library allocates a buffer. - **size** (tmsize_t) - Required - The size of the buffer. #### TIFFWriteBufferSetup - **tif** (TIFF *) - Required - Handle to the TIFF file. - **buffer** (void *) - Required/Optional - Pointer to the buffer to use. If NULL, the library allocates a buffer. - **size** (tmsize_t) - Required - The size of the buffer. If -1, the library selects an appropriate size. ### Return Value - **int** - Non-zero if the setup was successful, zero otherwise. ### Diagnostics - `%s: No space for data buffer at scanline %ld`: `TIFFReadBufferSetup()` failed to allocate a data buffer. - `%s: No space for output buffer`: `TIFFWriteBufferSetup()` failed to allocate an output buffer. ### See Also - libtiff(3tiff) ``` -------------------------------- ### Get TIFF Client Data Source: https://libtiff.gitlab.io/libtiff/functions/TIFFOpen.html Retrieves the client data handle associated with a TIFF structure. This is the handle passed during client open. ```c thandle_t TIFFClientdata(TIFF *tif) ``` -------------------------------- ### TIFFCIELabToRGBInit Source: https://libtiff.gitlab.io/libtiff/functions/TIFFcolor.html Initializes the TIFFCIELabToRGB structure for CIELab to RGB conversion. ```APIDOC ## TIFFCIELabToRGBInit ### Description Initializes the TIFFCIELabToRGB structure with display characteristics and reference white for CIELab to RGB conversion. ### Method N/A (This is a function signature, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### TIFFGetField Example for Unsupported Tags Source: https://libtiff.gitlab.io/libtiff/functions/TIFFGetField.html Demonstrates how to retrieve values for unsupported TIFF tags by specifying their tag ID and data type. ```APIDOC ## TIFFGetField for Unsupported Tags ### Description This example shows how to read values from TIFF tags that are not directly supported by libtiff by using the generic `TIFFGetField` function. ### Method `TIFFGetField` ### Parameters - **tiff** (TIFF*) - Pointer to the TIFF file structure. - **tag_id** (uint32_t) - The integer ID of the TIFF tag to retrieve. - **&count** (uint32_t*) - Pointer to a uint32_t to store the count of data elements. - **&data** (void**) - Pointer to a void pointer that will store the address of the retrieved data. ### Request Example ```c uint32_t count; void *data; // Example for tag 33424 (LONG) TIFFGetField(tiff, 33424, &count, &data); printf("Tag %d: %d, count %d\n", 33424, *(uint32_t *)data, count); // Example for tag 36867 (ASCII) TIFFGetField(tiff, 36867, &count, &data); printf("Tag %d: %s, count %d\n", 36867, (char *)data, count); ``` ### Response #### Success Response (200) - **count** (uint32_t) - The number of data elements associated with the tag. - **data** (void*) - A pointer to the data associated with the tag. The type of data depends on the tag. #### Response Example ``` Tag 33424: 12345, count 1 Tag 36867: "Example ASCII String", count 17 ``` ### Diagnostics - `Unknown field, tag 0x%x`: An unknown tag was supplied. ``` -------------------------------- ### Byte Order Configuration Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFOpen.rst.txt Use 'b' or 'l' flags with file opening modes to force specific byte ordering, such as 'wb' or 'wl'. ```text wb ``` ```text wl ``` -------------------------------- ### ppm2tiff Command Line Options Source: https://libtiff.gitlab.io/libtiff/genindex.html Command-line options for the ppm2tiff utility. ```APIDOC ## ppm2tiff Command Line Options Options for the `ppm2tiff` command-line utility. ### -c ### -r ### -R ``` -------------------------------- ### C Configuration Options Source: https://libtiff.gitlab.io/libtiff/genindex.html Command-line options for the configure script used to build libtiff. ```APIDOC ## C Configuration Options These are the command-line options available for the `configure` script when building libtiff. ### --bindir ### --datadir ### --datarootdir ### --disable-jpeg ### --docdir ### --enable-ld-version-script ### --enable-rpath ### --enable-shared ### --enable-static ### --exec-prefix ### --htmldir ### --includedir ### --libdir ### --libexecdir ### --localedir ### --localstatedir ### --mandir ### --oldincludedir ### --prefix ### --program-prefix ### --program-suffix ### --program-transform-name ### --sbindir ### --sharedstatedir ### --sysconfdir ### --with-jpeg-include-dir ### --with-jpeg-lib-dir ``` -------------------------------- ### Initialize CIELab to RGB Conversion Source: https://libtiff.gitlab.io/libtiff/functions/TIFFcolor.html Initializes the TIFFCIELabToRGB structure for CIELab to RGB conversion. Requires display white point and reference white values. ```c int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *displayw, float *refWhite); ``` -------------------------------- ### Validate BitsPerSample in JPEG Setup Source: https://libtiff.gitlab.io/libtiff/_sources/releases/v4.0.8.rst.txt Ensures BitsPerSample is validated in JPEGSetupEncode to prevent undefined behavior from invalid shift exponents. Fixes bugzilla:2648. ```c /* validate BitsPerSample in JPEGSetupEncode to avoid undefined behaviour caused by invalid shift exponent. Fixes bugzilla:2648 */ ``` -------------------------------- ### Get Bit Reversal Table Source: https://libtiff.gitlab.io/libtiff/functions/TIFFswab.html Retrieves a lookup table for bit reversal. Supply 1 for a bit reversal table, or 0 for an identity table. ```c const unsigned char *TIFFGetBitRevTable(int reversed) ``` -------------------------------- ### raw2tiff Command Line Options Source: https://libtiff.gitlab.io/libtiff/genindex.html Command-line options for the raw2tiff utility. ```APIDOC ## raw2tiff Command Line Options Options for the `raw2tiff` command-line utility. ### -c ### -d ### -H ### -i ### -L ### -M ### -p ### -s ### -w ``` -------------------------------- ### Get Strile Offset Source: https://libtiff.gitlab.io/libtiff/functions/TIFFStrileQuery.html Retrieves the offset for a specific strile. This function helps in locating the data for individual strips or tiles within the TIFF file. ```c uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile); ``` -------------------------------- ### Write Custom Directory and Get Offset Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFCustomDirectory.rst.txt Write the custom directory to the file using TIFFWriteCustomDirectory. The offset to this directory in the file is returned in the provided pointer. ```c TIFFWriteCustomDirectory(tiffOut, &dir_offset); ``` -------------------------------- ### Link user32.lib in windowed mode for nmake.opt Source: https://libtiff.gitlab.io/libtiff/releases/v3.7.1.html Modifies the nmake.opt file to link with `user32.lib` when operating in windowed mode, addressing a bug reported in Remote Sensing bugzilla #697. ```makefile nmake.opt: Link with the `user32.lib` in windowed mode. As per bug Remote Sensing bugzilla #697 [no longer available] ``` -------------------------------- ### Get TIFF Field by Tag Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFFieldQuery.rst.txt Retrieves a pointer to the TIFF field information structure using the tag number. Returns NULL if the tag is not registered. ```c #include const TIFFField* TIFFFieldWithTag(TIFF* tif, uint32_t tag) ``` -------------------------------- ### CLI Usage: ppm2tiff Source: https://libtiff.gitlab.io/libtiff/tools/ppm2tiff.html Command-line interface documentation for converting image files to TIFF format. ```APIDOC ## CLI Command: ppm2tiff ### Description Converts a file in the PPM, PGM, or PBM image formats to TIFF. If no input file is specified, it reads from standard input. ### Usage ppm2tiff [options] [input.ppm] output.tif ### Options - **-c** (string) - Optional - Specify a compression scheme: none, packbits (default), lzw, jpeg, zip, g3, or g4. - **-r** (integer) - Optional - Specify the number of rows per strip. - **-R** (integer) - Optional - Specify the X and Y resolution in dots/inch. ``` -------------------------------- ### Get Configured TIFF Codecs Source: https://libtiff.gitlab.io/libtiff/functions/TIFFcodec.html Retrieve a list of all configured TIFF codecs, including built-in and user-registered ones. The caller is responsible for freeing the returned array. ```c TIFFCodec *TIFFGetConfiguredCODECs(uint16_t scheme); ``` -------------------------------- ### Get TIFF Library Version Source: https://libtiff.gitlab.io/libtiff/_sources/libtiff.rst.txt Retrieve the software version information of the TIFF library. This can be checked at compile time using TIFFLIB_VERSION or at runtime using TIFFGetVersion. ```shell cat VERSION cat dist/tiff.alpha ``` ```c #include // ... const char *version_string = TIFFGetVersion(); // TIFFLIB_VERSION can be used for compile-time checks ``` -------------------------------- ### Get TIFF Field by Name Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFFieldQuery.rst.txt Retrieves a pointer to the TIFF field information structure using the field's name. Returns NULL if the tag is not registered. ```c #include const TIFFField* TIFFFieldWithName(TIFF* tif, const char *field_name) ``` -------------------------------- ### In-Source Build with CMake Source: https://libtiff.gitlab.io/libtiff/_sources/build.rst.txt Configures and builds the software within the source directory. Requires unpacking the tarball first. ```shell $ gzip -dc tiff-4.0.5.tar.gz | tar -xf - $ cd ./tiff-4.0.5 $ cmake $ make $ make test $ make install ``` -------------------------------- ### Create and Set Fields for Custom/GPS Directory Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFCustomDirectory.rst.txt Create a custom directory using TIFFCreateCustomDirectory or a predefined one like GPS using TIFFCreateGPSDirectory. Subsequently, set fields for this new directory using TIFFSetField. ```c TIFFCreateCustomDirectory(tiffOut, infoarray); /* for a real custom directory */ /* or alternatively, use GPS or EXIF with pre-defined TIFFFieldArray IFD field structure */ TIFFCreateGPSDirectory(tiffOut); TIFFSetField(tiffOut, GPSTAG_VERSIONID, gpsVersion); /* set fields of the custom directory */ ``` -------------------------------- ### Access TIFFTagMethods Source: https://libtiff.gitlab.io/libtiff/_sources/functions/TIFFAccessTagMethods.rst.txt Use this function to get read/write access to the TIFFTagMethods structure associated with a TIFF file. Ensure the TIFF structure is properly opened before calling. ```c #include TIFFTagMethods *TIFFAccessTagMethods(TIFF* tif) ```