1 .\" $Header: /d1/sam/tiff/man/RCS/libtiff.3t,v 1.25 1997/08/29 21:48:21 sam Exp $
3 .\" Copyright (c) 1988-1997 Sam Leffler
4 .\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 .\" Permission to use, copy, modify, distribute, and sell this software and
7 .\" its documentation for any purpose is hereby granted without fee, provided
8 .\" that (i) the above copyright notices and this permission notice appear in
9 .\" all copies of the software and related documentation, and (ii) the names of
10 .\" Sam Leffler and Silicon Graphics may not be used in any advertising or
11 .\" publicity relating to the software without the specific, prior written
12 .\" permission of Sam Leffler and Silicon Graphics.
14 .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 .TH INTRO 3T "August 21, 1997"
28 libtiff \- introduction to
30 a library for reading and writing
34 .B "#include <tiffio.h>"
40 is a library for reading and writing data files encoded with the
42 format, Revision 6.0 (or revision 5.0 or revision 4.0).
43 This file format is suitable for archiving multi-color and
44 monochromatic image data.
46 The library supports several compression algorithms, as indicated
52 1D Huffman compression (2),
54 Group 3 Facsimile compression (3),
56 Group 4 Facsimile compression (4),
57 Lempel-Ziv & Welch compression (5),
58 baseline JPEG compression (7),
59 word-aligned 1D Huffman compression (32771),
61 PackBits compression (32773).
62 In addition, several nonstandard compression algorithms are supported:
63 the 4-bit compression algorithm used
66 program (32809) (decompression only),
67 NeXT's 2-bit compression algorithm (32766) (decompression only),
68 an experimental LZ-style algorithm known as Deflate (32946), and
69 an experimental CIE LogLuv compression scheme designed for images
70 with high dynamic range (32845 for LogL and 32845 for LogLuv).
71 Directory information may be in either little- or big-endian byte
72 order\-byte swapping is automatically done by the library.
73 Data bit ordering may be either Most Significant Bit (\c
75 ) to Least Significant Bit (\c
81 Finally, the library does not support files in which the
87 fields are defined differently on a per-sample basis
90 tag is not defined on a per-sample basis, so this is immaterial).
92 The library makes extensive use of C typedefs to promote portability.
93 Two sets of typedefs are used, one for communication with clients
94 of the library and one for internal data structures and parsing of the
97 The following typedefs are exposed to users either through
98 function definitions or through parameters passed through the
102 .ta +\w'typedef unsigned <\fIthing\fP> uint32; 'u
104 typedef unsigned short uint16; 16-bit unsigned integer
105 typedef unsigned <\fIthing\fP> uint32; 32-bit unsigned integer
107 typedef unsigned int ttag_t; directory tag
108 typedef uint16 tdir_t; directory index
109 typedef uint16 tsample_t; sample number
110 typedef uint32 tstrip_t; strip number
111 typedef uint32 ttile_t; tile number
112 typedef int32 tsize_t; i/o size in bytes
113 typedef void* tdata_t; image data ref
114 typedef void* thandle_t; client data handle
115 typedef int32 toff_t; file offset
124 are constrained to be no more than 32-bit quantities by
125 32-bit fields they are stored in in the
130 is limited by the 16-bit field used to store the
134 constrains the maximum number of
136 that may appear in an image and may be an arbitrary size (w/o penalty).
138 must be either int, unsigned int, pointer, or double because
139 the library uses a varargs interface and
141 restricts the type of the parameter before an ellipsis to be a
144 is defined as int32 because TIFF file offsets are (unsigned) 32-bit
146 A signed value is used because some interfaces return \-1 on error.
147 Finally, note that user-specified data references are
148 passed as opaque handles and only cast at the lowest layers where
149 their type is presumed.
150 .SH "LIST OF ROUTINES"
151 The following routines are part of the library.
152 Consult specific manual pages for details on their operation.
153 The manual page names listed below are for systems
154 where the full function names can not be encoded in the filesystem;
155 on most systems doing ``man function-name'' will work.
158 .ta \w'TIFFWriteEncodedStrip'u+2n +\w'Appears on Page'u+2n
159 \fIName\fP \fIAppears on Page\fP \fIDescription\fP
161 TIFFCheckTile tile.3t very x,y,z,sample is within image
162 TIFFClientOpen open.3t open a file for reading or writing
163 TIFFClose close.3t close an open file
164 TIFFComputeStrip strip.3t return strip containing y,sample
165 TIFFComputeTile tile.3t return tile containing x,y,z,sample
166 TIFFCurrentDirectory query.3t return index of current directory
167 TIFFCurrentRow query.3t return index of current scanline
168 TIFFCurrentStrip query.3t return index of current strip
169 TIFFCurrentTile query.3t return index of current tile
170 TIFFError error.3t library error handler
171 TIFFFdOpen open.3t open a file for reading or writing
172 TIFFFileName query.3t return name of open file
173 TIFFFileno query.3t return open file descriptor
174 TIFFFlush flush.3t flush all pending writes
175 TIFFFlushData flush.3t flush pending data writes
176 TIFFGetBitRevTable swab.3t return bit reversal table
177 TIFFGetField getfield.3t return tag value in current directory
178 TIFFGetFieldDefaulted getfield.3t return tag value in current directory
179 TIFFGetMode query.3t return open file mode
180 TIFFGetVersion query.3t return library version string
181 TIFFIsTiled query.3t return true if image data is tiled
182 TIFFIsByteSwapped query.3t return true if image data is byte-swapped
183 TIFFNumberOfStrips strip.3t return number of strips in an image
184 TIFFNumberOfTiles tile.3t return number of tiles in an image
185 TIFFOpen open.3t open a file for reading or writing
186 TIFFPrintDirectory print.3t print description of the current directory
187 TIFFReadBufferSetup rdbuf.3t specify i/o buffer for reading
188 TIFFReadDirectory readdir.3t read the next directory
189 TIFFReadEncodedStrip rdestrip.3t read and decode a strip of data
190 TIFFReadEncodedTile rdetile.3t read and decode a tile of data
191 TIFFReadRawStrip rdrstrip.3t read a raw strip of data
192 TIFFReadRawTile rdrtile.3t read a raw tile of data
193 TIFFReadRGBAImage rdimage.3t read an image into a fixed format raster
194 TIFFReadScanline readline.3t read and decode a row of data
195 TIFFReadTile readtile.3t read and decode a tile of data
196 TIFFReverseBits swab.3t reverse bits in an array of bytes
197 TIFFRGBAImageBegin rgbaimage.3t setup decoder state for TIFFRGBAImageGet
198 TIFFRGBAImageEnd rgbaimage.3t release TIFFRGBAImage decoder state
199 TIFFRGBAImageGet rgbaimage.3t read and decode an image
200 TIFFRGBAImageOK rgbaimage.3t is image readable by TIFFRGBAImageGet
201 TIFFScanlineSize size.3t return size of a scanline
202 TIFFSetDirectory setdir.3t set the current directory
203 TIFFSetSubDirectory setdir.3t set the current directory
204 TIFFSetErrorHandler error.3t set error handler function
205 TIFFSetField setfield.3t set a tag's value in the current directory
206 TIFFSetWarningHandler error.3t set warning handler function
207 TIFFStripSize size.3t return size of a strip
208 TIFFSwabShort swab.3t swap bytes of short
209 TIFFSwabLong swab.3t swap bytes of long
210 TIFFSwabArrayOfShort swab.3t swap bytes of an array of shorts
211 TIFFSwabArrayOfLong swab.3t swap bytes of an array of longs
212 TIFFTileRowSize size.3t return size of a row in a tile
213 TIFFTileSize size.3t return size of a tile
214 TIFFVGetField getfield.3t return tag value in current directory
215 TIFFVGetFieldDefaulted getfield.3t return tag value in current directory
216 TIFFVSetField setfield.3t set a tag's value in the current directory
217 TIFFWarning warning.3t library warning handler
218 TIFFWriteDirectory writedir.3t write the current directory
219 TIFFWriteEncodedStrip wrestrip.3t compress and write a strip of data
220 TIFFWriteEncodedTile wretile.3t compress and write a tile of data
221 TIFFWriteRawStrip wrrstrip.3t write a raw strip of data
222 TIFFWriteRawTile wrrtile.3t write a raw tile of data
223 TIFFWriteScanline writeline.3t write a scanline of data
224 TIFFWriteTile wrrtile.3t compress and write a tile of data
227 The table below lists the
229 tags that are recognized and handled by the library.
230 If no use is indicated in the table, then the library
231 reads and writes the tag, but does not use it internally.
232 Note that some tags are meaningful only when a particular
233 compression scheme is being used; e.g.
240 Tags of this sort are considered
242 tags and the library does not recognize them except when the
244 tag has been previously set to the relevant compression scheme.
247 .ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Value'u+2n +\w'R/W'u+2n
248 \fITag Name\fP \fIValue\fP \fIR/W\fP \fILibrary Use/Notes\fP
253 BitsPerSample 258 R/W lots
254 CellLength 265 parsed but ignored
255 CellWidth 264 parsed but ignored
258 ColorResponseUnit 300 parsed but ignored
259 Compression 259 R/W choosing codec
260 ConsecutiveBadFaxLines 328 R/W
261 DataType 32996 R obsoleted by SampleFormat tag
265 ExtraSamples 338 R/W lots
266 FaxRecvParams 34908 R/W
267 FaxSubAddress 34909 R/W
268 FaxRecvTime 34910 R/W
269 FillOrder 266 R/W control bit order
270 FreeByteCounts 289 parsed but ignored
271 FreeOffsets 288 parsed but ignored
272 GrayResponseCurve 291 parsed but ignored
273 GrayResponseUnit 290 parsed but ignored
274 Group3Options 292 R/W used by Group 3 codec
275 Group4Options 293 R/W
277 ImageDepth 32997 R/W tile/strip calculations
278 ImageDescription 270 R/W
279 ImageLength 257 R/W lots
280 ImageWidth 256 R/W lots
283 JPEGTables 347 R/W used by JPEG codec
285 Matteing 32995 R obsoleted by ExtraSamples tag
286 MaxSampleValue 281 R/W
287 MinSampleValue 280 R/W
289 NewSubFileType 254 R/W called SubFileType in spec
294 PhotometricInterpretation 262 R/W used by Group 3 and JPEG codecs
295 PlanarConfiguration 284 R/W data i/o
296 Predictor 317 R/W used by LZW and Deflate codecs
297 PrimaryChromacities 319 R/W
298 ReferenceBlackWhite 532 R/W
299 ResolutionUnit 296 R/W used by Group 3 codec
300 RowsPerStrip 278 R/W data i/o
302 SamplesPerPixel 277 R/W lots
303 SMinSampleValue 340 R/W
304 SMaxSampleValue 341 R/W
307 StripByteCounts 279 R/W data i/o
308 StripOffsets 273 R/W data i/o
309 SubFileType 255 R/W called OSubFileType in spec
310 TargetPrinter 337 R/W
312 TileByteCounts 324 R/W data i/o
313 TileDepth 32998 R/W tile/strip calculations
314 TileLength 323 R/W data i/o
315 TileOffsets 324 R/W data i/o
316 TileWidth 322 R/W data i/o
317 TransferFunction 301 R/W
321 YCbCrCoefficients 529 R/W used by TIFFRGBAImage support
322 YCbCrPositioning 531 R/W tile/strip size calulcations
323 YCbCrSubsampling 530 R/W
325 YResolution 283 R/W used by Group 3 codec
327 In addition to the normal
329 tags the library supports a collection of
330 tags whose values lie in a range outside the valid range of
333 These tags are termed
335 and are used to control various codec-specific functions within the library.
336 The table below summarizes the defined pseudo-tags.
339 .ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Codec'u+2n +\w'R/W'u+2n
340 \fITag Name\fP \fICodec\fP \fIR/W\fP \fILibrary Use/Notes\fP
343 TIFFTAG_FAXMODE G3 R/W general codec operation
344 TIFFTAG_FAXFILLFUNC G3/G4 R/W bitmap fill function
345 TIFFTAG_JPEGQUALITY JPEG R/W compression quality control
346 TIFFTAG_JPEGCOLORMODE JPEG R/W control colorspace conversions
347 TIFFTAG_JPEGTABLESMODE JPEG R/W control contents of \fIJPEGTables\fP tag
348 TIFFTAG_ZIPQUALITY Deflate R/W compression quality level
349 TIFFTAG_PIXARLOGDATAFMT PixarLog R/W user data format
350 TIFFTAG_PIXARLOGQUALITY PixarLog R/W compression quality level
351 TIFFTAG_SGILOGDATAFMT SGILog R/W user data format
355 Control the operation of the Group 3 codec.
356 Possible values (independent bits that can be combined by
357 or'ing them together) are:
359 (enable old-style format in which the
361 is written at the end of the last strip),
370 codes at the start of each row of data),
372 (align each encoded row to an 8-bit boundary),
374 (align each encoded row to an 16-bit boundary),
375 The default value is dependent on the compression scheme; this
376 pseudo-tag is used by the various G3 and G4 codecs to share code.
378 .B TIFFTAG_FAXFILLFUNC
379 Control the function used to convert arrays of black and white
380 runs to packed bit arrays.
381 This hook can be used to image decoded scanlines in multi-bit
382 depth rasters (e.g. for display in colormap mode)
383 or for other purposes.
384 The default value is a pointer to a builtin function that images
387 .B TIFFTAG_JPEGQUALITY
388 Control the compression quality level used in the baseline algorithm.
389 Note that quality levels are in the range 0-100 with a default value of 75.
391 .B TIFFTAG_JPEGCOLORMODE
392 Control whether or not conversion is done between
393 RGB and YCbCr colorspaces.
396 (do not convert), and
398 (convert to/from RGB)
399 The default value is JPEGCOLORMODE_RAW.
401 .B TIFFTAG_JPEGTABLESMODE
402 Control the information written in the
405 Possible values (independent bits that can be combined by
406 or'ing them together) are:
408 (include quantization tables),
411 (include Huffman encoding tables).
412 The default value is JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF.
414 .B TIFFTAG_ZIPQUALITY
415 Control the compression technique used by the Deflate codec.
416 Quality levels are in the range 1-9 with larger numbers yielding better
417 compression at the cost of more computation.
418 The default quality level is 6 which yields a good time-space tradeoff.
420 .B TIFFTAG_PIXARLOGDATAFMT
421 Control the format of user data passed
423 to the PixarLog codec when encoding and passed
428 for 8-bit unsigned pixels,
429 PIXARLOGDATAFMT_8BITABGR
430 for 8-bit unsigned ABGR-ordered pixels,
431 PIXARLOGDATAFMT_11BITLOG
432 for 11-bit log-encoded raw data,
433 PIXARLOGDATAFMT_12BITPICIO
434 for 12-bit PICIO-compatible data,
435 PIXARLOGDATAFMT_16BIT
436 for 16-bit signed samples,
438 PIXARLOGDATAFMT_FLOAT
439 for 32-bit IEEE floating point samples.
441 .B TIFFTAG_PIXARLOGQUALITY
442 Control the compression technique used by the PixarLog codec.
443 This value is treated identically to TIFFTAG_ZIPQUALITY; see the
446 .B TIFFTAG_SGILOGDATAFMT
447 Control the format of client data passed
449 to the SGILog codec when encoding and passed
454 for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels,
455 SGILOGDATAFMT_16BITLUV
456 for 16-bit encoded Luv pixels,
457 SGILOGDATAFMT_32BITRAW and SGILOGDATAFMT_24BITRAW
458 for no conversion of data,
459 SGILOGDATAFMT_8BITRGB
460 for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data),
462 for converting between LogL and 32-bit IEEE floating valued Y pixels,
464 for 16-bit encoded L pixels,
466 SGILOGDATAFMT_8BITGRY
467 for returning 8-bit greyscale data
468 (valid only when decoding LogL-encoded data).
470 All error messages are directed through the
473 By default messages are directed to
476 .IR "module: message\en."
477 Warning messages are likewise directed through the
499 .IR "Tag Image File Format Specification \(em Revision 6.0" ,
500 an Aldus Technical Memorandum.
502 .IR "The Spirit of TIFF Class F" ,
503 an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies.
505 The library does not support multi-sample images
506 where some samples have different bits/sample.
508 The library does not support random access to compressed data
509 that is organized with more than one row per tile or strip.
510 The library discards unknown tags.
511 The library should do more validity checking of a directory's contents.