libtiff - introduction to libtiff, a library for reading and writing TIFF files
cc [ flag ...] -I/usr/sfw/include file [ library ... ] -L/usr/sfw/lib -R/usr/sfw/lib -ltiff
libtiff is a library for reading and writing data files encoded with the Tag Image File format, Revision 4.0 or later. The TIFF file format is suitable for archiving multicolor and monochromatic image data.
The libtiff library supports several compression algorithms, as indicated by the Compression field, including:
o No compression (1)
o CCITT 1D Huffman compression (2)
o CCITT Group 3 Facsimile compression (3)
o CCITT Group 4 Facsimile compression (4)
o Lempel-Ziv & Welch compression (5)
o Baseline JPEG compression (7)
o Word-aligned 1D Huffman compression (32771)
o PackBits compression (32773)
In addition, several nonstandard compression algorithms are supported:
o 4-bit compression algorithm used by the ThunderScan program (32809) (decompression only)
o NeXTs 2-bit compression algorithm (32766) (decompression only)
o Experimental LZ-style algorithm known as Deflate (32946)
o Experimental CIE LogLuv compression scheme designed for images with high dynamic range (32845 for LogL and 32845 for LogLuv)
Directory information may be in either little- or big-endian byte order. Byte swapping is automatically done by the library.
Data bit ordering may be either Most Significant Bit (MSB) to Least Significant Bit (LSB), or LSB to MSB.
The library does not support files in which the BitsPerSample, Compression, MinSampleValue, or MaxSampleValue fields are defined differently on a per-sample basis. In Revision 6.0, the Compression tag is not defined on a per-sample basis, so this is immaterial.
The libtiff library makes extensive use of C typedefs to promote portability. Two sets of typedefs are used, one for communication with clients of the library and one for internal data structures and parsing of the TIFF format. The following typedefs are exposed to users either through function definitions or through parameters passed through the varargs interfaces.
o typedef unsigned short uint16; 16-bit unsigned integer
o typedef unsigned <thing> uint32; 32-bit unsigned integer
o typedef unsigned int ttag_t; directory tag
o typedef uint16 tdir_t; directory index
o typedef uint16 tsample_t; sample number
o typedef uint32 tstrip_t; strip number
o typedef uint32 ttile_t; tile number
o typedef int32 tsize_t; i/o size in bytes
o typedef void* tdata_t; image data ref
o typedef void* thandle_t; client data handle
o typedef int32 toff_t; file offset
tstrip_t, ttile_t, and tsize_t are limited to 32-bit quantities because they are stored in 32-bit fields in the TIFF image. Similarly, tsample_t is limited by the 16-bit field used to store the SamplesPerPixel tag. tdir_t constrains the maximum number of IFDs that may appear in an image and may be an arbitrary size without penalty.
ttag_t must be int, unsigned int, pointer, or double because the library uses a varargs interface and ANSI C restricts the type of the parameter before an ellipsis to be a promoted type.
toff_t is defined as int32 because TIFF file offsets are unsigned 32-bit quantities. A signed value is used because some interfaces return -1 on error.
User-specified data references are passed as opaque handles and only cast at the lowest layers where their type is presumed.
The following routines are part of the libtiff library. Consult specific reference pages for details on their operation. The reference page names listed below are for systems where the full function names cannot be encoded in the file system. On most systems, the command man function-name will work.
_TIFFfree Release allocated memory. See TIFFmemory(3tiff).
_TIFFmalloc Dynamically allocate memory. See TIFFmemory(3tiff).
_TIFFmemcmp Compare allocated memory. See TIFFmemory(3tiff).
_TIFFmemcpy Copy allocated memory to another memory location. See TIFFmemory(3tiff).
_TIFFmemset Set allocated memory to known value. See TIFFmemory(3tiff).
_TIFFrealloc Dynamically reallocate memory. See TIFFmemory(3tiff).
TIFFbuffer Specify i/o buffer for reading or writing. See TIFFbuffer(3tiff).
TIFFCheckTile Every x,y,z,sample is within image. See TIFFtile(3tiff).
TIFFClientOpen Open a file for reading or writing. See TIFFOpen(3tiff).
TIFFClose Close an open file. See TIFFClose(3tiff).
TIFFcodec Work with codecs. See TIFFcodec(3tiff).
TIFFComputeStrip Return strip containing x,y,z,sample. See TIFFstrip(3tiff).
TIFFComputeTile Return tile containing y,sample. See TIFFtile(3tiff).
TIFFCurrentDirectory Return index of current directory. See TIFFquery(3tiff).
TIFFCurrentRow Return index of current scanline. See TIFFquery(3tiff).
TIFFCurrentStrip Return index of current strip. See TIFFquery(3tiff).
TIFFCurrentTile Return index of current tile. See TIFFquery(3tiff).
TIFFDefaultStripSize Return size of a strip. See TIFFstrip(3tiff).
TIFFDefaultTileSize Return size of a tile. See TIFFtile(3tiff).
TIFFError Library error handler. See TIFFError(3tiff).
TIFFFdOpen Open a file for reading or writing. See TIFFOpen(3tiff).
TIFFFileName Return name of open file. See TIFFquery(3tiff).
TIFFFileno Return open file descriptor. See TIFFquery(3tiff).
TIFFFindCODEC Find a codec. See TIFFcodec(3tiff).
TIFFFlush Flush all pending writes. See TIFFFlush(3tiff).
TIFFFlushData Flush pending data writes. See TIFFFlush(3tiff).
TIFFGetBitRevTable Return bit reversal table. See TIFFswab(3tiff).
TIFFGetField Return tag value in current directory. See TIFFGetField(3tiff).
TIFFGetFieldDefaulted Return tag value in current directory. See TIFFGetField(3tiff).
TIFFGetMode Return open file mode. See TIFFquery(3tiff).
TIFFGetVersion Return library version string. See TIFFquery(3tiff).
TIFFIsByteSwapped Return true if image data is byte-swapped. See TIFFquery(3tiff).
TIFFIsMSB2LSB Return true if image data is returned with bit 0 as the most significant bit. See TIFFquery(3tiff).
TIFFIsTiled Return true if image data is tiled. See TIFFquery(3tiff).
TIFFIsUpSampled Return true if image data is up-sampled. See TIFFquery(3tiff).
TIFFLastDirectory Return a non-zero value if the current directory is the last directory in the file. See TIFFquery(3tiff).
TIFFmemory Manage memory. See TIFFmemory(3tiff).
TIFFNumberOfStrips Return number of strips in an image. See TIFFstrip(3tiff).
TIFFNumberOfTiles Return number of tiles in an image. See TIFFtile(3tiff).
TIFFOpen Open a file for reading or writing. See TIFFOpen(3tiff).
TIFFPrintDirectory Print description of the current directory. See TIFFPrintDirectory(3tiff).
TIFFquery Return information about image. See TIFFquery(3tiff).
TIFFRasterScanlineSize Return size of a raster scanline. See TIFFsize(3tiff).
TIFFReadBufferSetup Specify i/o buffer for reading. See TIFFbuffer(3tiff).
TIFFReadDirectory Read the next directory. See TIFFReadDirectory(3tiff).
TIFFReadEncodedStrip Read and decode a strip of data. See TIFFReadEncodedStrip(3tiff).
TIFFReadEncodedTile Read and decode a tile of data. See TIFFReadEncodedTile(3tiff).
TIFFReadRawStrip Read a raw strip of data. See TIFFReadRawStrip(3tiff).
TIFFReadRawTile Read a raw tile of data. See TIFFReadRawTile(3tiff).
TIFFReadRGBAImage Read an image into a fixed format raster. See TIFFReadRGBAImage(3tiff).
TIFFReadRGBAStrip Read an image strip into a fixed format raster. See TIFFReadRGBAStrip(3tiff).
TIFFReadRGBATile Read an image tile into a fixed format raster. See TIFFReadRGBATile(3tiff).
TIFFReadScanline Read and decode a row of data. See TIFFReadScanline(3tiff).
TIFFReadTile Read and decode a tile of data. See TIFFReadTile(3tiff).
TIFFRegisterCODEC Register a codec. See TIFFcodec(3tiff).
TIFFReverseBits Reverse bits in an array of bytes. See TIFFswab(3tiff).
TIFFRGBAImage Read and decode an image into a raster. See TIFFRGBAImage(3tiff).
TIFFRGBAImageBegin Set up decoder state for TIFFRGBAImageGet. See TIFFRGBAImage(3tiff).
TIFFRGBAImageEnd Release TIFFRGBAImage decoder state. See TIFFRGBAImage(3tiff).
TIFFRGBAImageGet Read and decode an image. See TIFFRGBAImage(3tiff).
TIFFRGBAImageOK Determine whether image is readable by TIFFRGBAImageGet. See TIFFRGBAImage(3tiff).
TIFFScanlineSize Return size of a scanline. See TIFFsize(3tiff).
TIFFSetDirectory Set the current directory. See TIFFSetDirectory(3tiff).
TIFFSetSubDirectory Set the current directory. See TIFFSetDirectory(3tiff).
TIFFSetErrorHandler Set error handler function. See TIFFError(3tiff).
TIFFSetField Set tag value in the current directory. See TIFFSetField(3tiff).
TIFFSetWarningHandler Set warning handler function. See TIFFWarning(3tiff).
TIFFsize Return the size. See TIFFsize(3tiff).
TIFFstrip Work with strips. See TIFFstrip(3tiff).
TIFFStripSize Return size of a strip. See TIFFstrip(3tiff).
TIFFswab Swap bytes. See TIFFswab(3tiff).
TIFFSwabShort Swap bytes of short. See TIFFswab(3tiff).
TIFFSwabLong Swap bytes of long. See TIFFswab(3tiff).
TIFFSwabArrayOfShort Swap bytes of an array of shorts. See TIFFswab(3tiff).
TIFFSwabArrayOfLong Swap bytes of an array of longs. See TIFFswab(3tiff).
TIFFtile Return tile information. See TIFFtile(3tiff).
TIFFTileRowSize Return size of a row in a tile. See TIFFtile(3tiff).
TIFFTileSize Return size of a tile. See TIFFtile(3tiff).
TIFFUnregisterCODEC Unregister a codec. See TIFFcodec(3tiff).
TIFFVGetField Return tag value in current directory. See TIFFGetField(3tiff).
TIFFVGetFieldDefaulted Return tag value in current directory. See TIFFGetField(3tiff).
TIFFVSetField Set tag value in current directory. See TIFFSetField(3tiff).
TIFFVStripSize Return size of a strip. See TIFFstrip(3tiff).
TIFFVTileSize Return size of a tile. See TIFFtile(3tiff).
TIFFWarning Library warning handler. See TIFFWarning(3tiff).
TIFFWriteBufferSetup Specify i/o buffer for writing. See TIFFbuffer(3tiff).
TIFFWriteDirectory Write the current directory. See TIFFWriteDirectory(3tiff).
TIFFWriteEncodedStrip Compress and write a strip of data. See TIFFWriteEncodedStrip(3tiff).
TIFFWriteEncodedTile Compress and write a tile of data. See TIFFWriteEncodedTile(3tiff).
TIFFWriteRawStrip Write a raw strip of data. See TIFFWriteRawStrip(3tiff).
TIFFWriteRawTile Write a raw tile of data. See TIFFWriteRawTile(3tiff).
TIFFWriteScanline Write a scanline of data. See TIFFWriteScanline(3tiff).
TIFFWriteTile Compress and write a tile of data. See TIFFWriteTile(3tiff).
The table below lists the TIFF tags that are recognized and supported by the libtiff library. If no use is indicated in the table, then the library reads and writes the tag, but does not use the tag internally. Note that some tags are meaningful only when a particular compression scheme is used. For example, Group3Options is only useful if Compression is set to CCITT Group 3 encoding. Tags of this sort are considered codec-specific tags and the library does not recognize them except when the Compression tag has been previously set to the relevant compression scheme.
TAG NAME VALUE R/W LIBRARY USE / NOTES Artist 315 R/W BadFaxLines 326 R/W BitsPerSample 258 R/W Lots. CellLength 265 Parsed but ignored. CellWidth 264 Parsed but ignored. CleanFaxData 327 R/W ColorMap 320 R/W ColorResponseUnit 300 Parsed but ignored. Compression 259 R/W Choosing codec. ConsecutiveBadFaxLines 328 R/W DataType 32996 R Obsoleted by SampleFormat tag. DateTime 306 R/W DocumentName 269 R/W DotRange 336 R/W ExtraSamples 338 R/W Lots. FaxRecvParams 34908 R/W FaxSubAddress 34909 R/W FaxRecvTime 34910 R/W FillOrder 266 R/W Control bit order. FreeByteCounts 289 Parsed but ignored. FreeOffsets 288 Parsed but ignored. GrayResponseCurve 291 Parsed but ignored. GrayResponseUnit 290 Parsed but ignored. Group3Options 292 R/W Used by Group 3 codec. Group4Options 293 R/W HostComputer 316 R/W ImageDepth 32997 R/W Tile/strip calculations. ImageDescription 270 R/W ImageLength 257 R/W Lots. ImageWidth 256 R/W Lots. InkNames 333 R/W InkSet 332 R/W JPEGTables 347 R/W Used by JPEG codec. Make 271 R/W Matteing 32995 R Obsoleted by ExtraSamples tag. MaxSampleValue 281 R/W MinSampleValue 280 R/W Model 272 R/W NewSubFileType 254 R/W Called SubFileType in spec. NumberOfInks 334 R/W Orientation 274 R/W PageName 285 R/W PageNumber 297 R/W PhotometricInterpretation 262 R/W Used by Group 3 and JPEG codecs. PlanarConfiguration 284 R/W Data i/o. Predictor 317 R/W Used by LZW and Deflate codecs. PrimaryChromacities 319 R/W ReferenceBlackWhite 532 R/W ResolutionUnit 296 R/W Used by Group 3 codec. RowsPerStrip 278 R/W Data i/o. SampleFormat 339 R/W SamplesPerPixel 277 R/W Lots. SMinSampleValue 340 R/W SMaxSampleValue 341 R/W Software 305 R/W StoNits 37439 R/W StripByteCounts 279 R/W Data i/o. StripOffsets 273 R/W Data i/o. SubFileType 255 R/W Called OSubFileType in spec. TargetPrinter 337 R/W Thresholding 263 R/W TileByteCounts 324 R/W Data i/o. TileDepth 32998 R/W Tile/strip calculations. TileLength 323 R/W Data i/o. TileOffsets 324 R/W Data i/o. TileWidth 322 R/W Data i/o. TransferFunction 301 R/W WhitePoint 318 R/W XPosition 286 R/W XResolution 282 R/W YCbCrCoefficients 529 R/W Used by TIFFRGBAImage support. YCbCrPositioning 531 R/W Tile/strip size calulcations. YCbCrSubsampling 530 R/W YPosition 286 R/W YResolution 283 R/W Used by Group 3 codec.
In addition to the normal TIFF tags, the libtiff library supports a collection of tags whose values lie in a range outside the valid range of TIFF tags. These tags are termed pseudo-tags and are used to control various codec-specific functions within the library. The table below summarizes the defined pseudo-tags.
TAG NAME CODEC R/W LIBRARY USE / NOTES TIFFTAG_FAXMODE G3 R/W General codec operation. TIFFTAG_FAXFILLFUNC G3/G4 R/W Bitmap fill function. TIFFTAG_JPEGQUALITY JPEG R/W Compression quality control. TIFFTAG_JPEGCOLORMODE JPEG R/W Control colorspace conversions. TIFFTAG_JPEGTABLESMODE JPEG R/W Control contents of JPEGTables tag. TIFFTAG_ZIPQUALITY Deflate R/W Compression quality level. TIFFTAG_PIXARLOGDATAFMT PixarLog R/W User data format. TIFFTAG_PIXARLOGQUALITY PixarLog R/W Compression quality level. TIFFTAG_SGILOGDATAFMT SGILog R/W User data format.
Controls the operation of the Group 3 codec. Possible values (independent bits that can be combined by oring them together) are:
FAXMODE_BYTEALIGN Align each encoded row to an 8-bit boundary.
FAXMODE_CLASSIC Enable old-style format in which the RTC is written at the end of the last strip.
FAXMODE_NOEOL Do not write EOL codes at the start of each row of data.
FAXMODE_NORTC, also called FAXMODE_CLASSF Opposite of FAXMODE_CLASSIC.
FAXMODE_WORDALIGN Align each encoded row to a 16-bit boundary.
The default value depends on the compression scheme. This pseudo-tag is used by the various G3 and G4 codecs to share code.
Controls the function used to convert arrays of black and white runs to packed bit arrays. This hook can be used to image decoded scanlines in multi-bit depth rasters (for example, for display in colormap mode) or for other purposes. The default value is a pointer to a builtin function that images packed bilevel data.
Contains image metadata per the IPTC newsphoto specification: Headline, captioning, credit, and so on. Used by most wire services.
Contains Photoshop captioning information and metadata. Photoshop uses in parallel and redundantly alongside IPTCNEWSPHOTO information.
Controls the compression quality level used in the baseline algorithm. Note that quality levels are in the range 0-100 with a default value of 75.
Controls whether or not conversion is done between RGB and YCbCr colorspaces. Possible values are: JPEGCOLORMODE_RAW (do not convert), and JPEGCOLORMODE_RGB (convert to/from RGB). The default value is JPEGCOLORMODE_RAW.
Controls the information written in the JPEGTables tag. Possible values (independent bits that can be combined by oring them together) are: JPEGTABLESMODE_QUANT (include quantization tables), and JPEGTABLESMODE_HUFF (include Huffman encoding tables).
Controls the compression technique used by the Deflate codec. Quality levels are in the range 1-9 with larger numbers yielding better compression at the cost of more computation. The default quality level is 6 which yields a good time-space tradeoff.
Controls the format of user data passed to the PixarLog codec when encoding and passed from the PixarLog codec when decoding. Possible values are:
o PIXARLOGDATAFMT_8BIT for 8-bit unsigned pixels
o PIXARLOGDATAFMT_8BITABGR for 8-bit unsigned ABGR-orderedpixels
o PIXARLOGDATAFMT_11BITLOG for 11-bit log-encoded raw data
o PIXARLOGDATAFMT_12BITPICIO for 12-bit PICIO-compatible data
o PIXARLOGDATAFMT_16BIT for 16-bit signed samples
o PIXARLOGDATAFMT_FLOAT for 32-bit IEEE floating point samples
Controls the compression technique used by the PixarLog codec. This value is treated identically to TIFFTAG_ZIPQUALITY.
Controls the format of client data passed to the SGILog codec when encoding and passed from the SGILog codec when decoding. Possible values are:
o SGILOGDATAFMT_FLTXYZ for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels
o SGILOGDATAFMT_16BITLUV for 16-bit encoded Luv pixels
o SGILOGDATAFMT_32BITRAW and SGILOGDATAFMT_24BITRAW for no conversion of data
o SGILOGDATAFMT_8BITRGB for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data)
o SGILOGDATAFMT_FLTY for converting between LogL and 32-bit IEEE floating valued Y pixels
o SGILOGDATAFMT_16BITL for 16-bit encoded L pixels
o SGILOGDATAFMT_8BITGRY for returning 8-bit greyscale data (valid only when decoding LogL-encoded data)
All error messages are directed through the TIFFError routine. By default, messages are directed to stderr in the form: module: message\n. Warning messages are likewise directed through the TIFFWarning routine.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE Availability SUNWTiff Interface stability Evolving
fax2tiff(1), gif2tiff(1), pal2rgb(1), ppm2tiff(1), ras2tiff(1), rgb2ycbcr(1), sgi2tiff(1); tiff2bw(1); tiffcmp(1); tiffcp(1); tiffdither(1); tiffdump(1); tiffgt(1); tiffinfo(1); tiffmedian(1); tiffsplit(1); tiffsv(1)
Tag Image File Format Specification Revision 6.0, an Aldus Technical Memorandum.
The Spirit of TIFF Class F an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies.
The libtiff library does not support multisample images where some samples have different bits/sample.
The library does not support random access to compressed data that is organized with more than one row per tile or strip. The library discards unknown tags. The library should do more validity checking of a directorys contents.
This man page was originally written by Sam Leffler. Updated by Breda McColgan, Sun Microsystems Inc., 2004.
|SunOS 5.11||libtiff (3)||06 Apr 2004|