]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/man/libtiff.3tiff
make renderer independent of windowing system
[wxWidgets.git] / src / tiff / man / libtiff.3tiff
1 .\" $Id: libtiff.3tiff,v 1.3 2005/11/02 11:07:19 dron Exp $
2 .\"
3 .\" Copyright (c) 1988-1997 Sam Leffler
4 .\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
5 .\"
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.
13 .\"
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.
17 .\"
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
23 .\" OF THIS SOFTWARE.
24 .\"
25 .if n .po 0
26 .TH INTRO 3TIFF "November 2, 2005" "libtiff"
27 .SH NAME
28 libtiff \- introduction to
29 .IR libtiff ,
30 a library for reading and writing
31 .SM TIFF
32 files
33 .SH SYNOPSIS
34 .B "#include <tiffio.h>"
35 .sp
36 cc file.c
37 .B -ltiff
38 .SH DESCRIPTION
39 .I libtiff
40 is a library for reading and writing data files encoded with the
41 .I "Tag Image File"
42 format, Revision 6.0 (or revision 5.0 or revision 4.0). This file format is
43 suitable for archiving multi-color and monochromatic image data.
44 .PP
45 The library supports several compression algorithms, as indicated by the
46 .I Compression
47 field, including:
48 no compression (1),
49 .SM CCITT
50 1D Huffman compression (2),
51 .SM CCITT
52 Group 3 Facsimile compression (3),
53 .SM CCITT
54 Group 4 Facsimile compression (4),
55 Lempel-Ziv & Welch compression (5),
56 baseline JPEG compression (7),
57 word-aligned 1D Huffman compression (32771),
58 and
59 PackBits compression (32773).
60 In addition, several nonstandard compression algorithms are supported: the
61 4-bit compression algorithm used by the
62 .I ThunderScan
63 program (32809) (decompression only), NeXT's 2-bit compression algorithm
64 (32766) (decompression only), an experimental LZ-style algorithm known as
65 Deflate (32946), and an experimental CIE LogLuv compression scheme designed
66 for images with high dynamic range (32845 for LogL and 32845 for LogLuv).
67 Directory information may be in either little- or big-endian byte order\-byte
68 swapping is automatically done by the library. Data bit ordering may be either
69 Most Significant Bit (\c
70 .SM MSB\c
71 ) to Least Significant Bit (\c
72 .SM LSB\c
73 ) or
74 .SM LSB
75 to
76 .SM MSB.
77 Finally, the library does not support files in which the
78 .IR BitsPerSample ,
79 .IR Compression ,
80 .IR MinSampleValue ,
81 or
82 .IR MaxSampleValue
83 fields are defined differently on a per-sample basis
84 (in Rev. 6.0 the
85 .I Compression
86 tag is not defined on a per-sample basis, so this is immaterial).
87 .SH "DATA TYPES"
88 The library makes extensive use of C typedefs to promote portability.
89 Two sets of typedefs are used, one for communication with clients
90 of the library and one for internal data structures and parsing of the
91 .SM TIFF
92 format.
93 The following typedefs are exposed to users either through function
94 definitions or through parameters passed through the varargs interfaces.
95 .in +.5i
96 .sp 5p
97 .ta +\w'typedef unsigned <\fIthing\fP> uint32; 'u
98 .nf
99 typedef unsigned short uint16; 16-bit unsigned integer
100 typedef unsigned <\fIthing\fP> uint32; 32-bit unsigned integer
101 .sp 5p
102 typedef unsigned int ttag_t; directory tag
103 typedef uint16 tdir_t; directory index
104 typedef uint16 tsample_t; sample number
105 typedef uint32 tstrip_t; strip number
106 typedef uint32 ttile_t; tile number
107 typedef int32 tsize_t; i/o size in bytes
108 typedef void* tdata_t; image data ref
109 typedef void* thandle_t; client data handle
110 typedef int32 toff_t; file offset
111 .fi
112 .sp 5p
113 .in -.5i
114 Note that
115 .IR tstrip_t ,
116 .IR ttile_t ,
117 and
118 .I tsize_t
119 are constrained to be no more than 32-bit quantities by 32-bit fields they are
120 stored in in the
121 .SM TIFF
122 image.
123 Likewise
124 .I tsample_t
125 is limited by the 16-bit field used to store the
126 .I SamplesPerPixel
127 tag.
128 .I tdir_t
129 constrains the maximum number of
130 .SM IFDs
131 that may appear in an image and may be an arbitrary size (w/o penalty).
132 .I ttag_t
133 must be either int, unsigned int, pointer, or double because the library uses
134 a varargs interface and
135 .SM "ANSI C"
136 restricts the type of the parameter before an ellipsis to be a promoted type.
137 .I toff_t
138 is defined as int32 because TIFF file offsets are (unsigned) 32-bit
139 quantities. A signed value is used because some interfaces return \-1 on
140 error. Finally, note that user-specified data references are passed as opaque
141 handles and only cast at the lowest layers where their type is presumed.
142 .SH "LIST OF ROUTINES"
143 The following routines are part of the library. Consult specific manual pages
144 for details on their operation; on most systems doing ``man function-name''
145 will work.
146 .sp
147 .nf
148 .ta \w'TIFFCheckpointDirectory'u+2n
149 \fIName\fP \fIDescription\fP
150 .sp 5p
151 TIFFCheckpointDirectory writes the current state of the directory
152 TIFFCheckTile very x,y,z,sample is within image
153 TIFFCIELabToRGBInit initialize CIE L*a*b* 1976 to RGB conversion state
154 TIFFCIELabToXYZ perform CIE L*a*b* 1976 to CIE XYZ conversion
155 TIFFClientOpen open a file for reading or writing
156 TIFFClose close an open file
157 TIFFComputeStrip return strip containing y,sample
158 TIFFComputeTile return tile containing x,y,z,sample
159 TIFFCurrentDirectory return index of current directory
160 TIFFCurrentRow return index of current scanline
161 TIFFCurrentStrip return index of current strip
162 TIFFCurrentTile return index of current tile
163 TIFFDataWidth return the size of TIFF data types
164 TIFFError library error handler
165 TIFFFdOpen open a file for reading or writing
166 TIFFFileName return name of open file
167 TIFFFileno return open file descriptor
168 TIFFFindCODEC find standard codec for the specific scheme
169 TIFFFlush flush all pending writes
170 TIFFFlushData flush pending data writes
171 TIFFGetBitRevTable return bit reversal table
172 TIFFGetField return tag value in current directory
173 TIFFGetFieldDefaulted return tag value in current directory
174 TIFFGetMode return open file mode
175 TIFFGetVersion return library version string
176 TIFFIsCODECConfigured check, whether we have working codec
177 TIFFIsMSB2LSB return true if image data is being returned
178 with bit 0 as the most significant bit
179 TIFFIsTiled return true if image data is tiled
180 TIFFIsByteSwapped return true if image data is byte-swapped
181 TIFFNumberOfStrips return number of strips in an image
182 TIFFNumberOfTiles return number of tiles in an image
183 TIFFOpen open a file for reading or writing
184 TIFFPrintDirectory print description of the current directory
185 TIFFReadBufferSetup specify i/o buffer for reading
186 TIFFReadDirectory read the next directory
187 TIFFReadEncodedStrip read and decode a strip of data
188 TIFFReadEncodedTile read and decode a tile of data
189 TIFFReadRawStrip read a raw strip of data
190 TIFFReadRawTile read a raw tile of data
191 TIFFReadRGBAImage read an image into a fixed format raster
192 TIFFReadScanline read and decode a row of data
193 TIFFReadTile read and decode a tile of data
194 TIFFRegisterCODEC override standard codec for the specific scheme
195 TIFFReverseBits reverse bits in an array of bytes
196 TIFFRGBAImageBegin setup decoder state for TIFFRGBAImageGet
197 TIFFRGBAImageEnd release TIFFRGBAImage decoder state
198 TIFFRGBAImageGet read and decode an image
199 TIFFRGBAImageOK is image readable by TIFFRGBAImageGet
200 TIFFScanlineSize return size of a scanline
201 TIFFSetDirectory set the current directory
202 TIFFSetSubDirectory set the current directory
203 TIFFSetErrorHandler set error handler function
204 TIFFSetField set a tag's value in the current directory
205 TIFFSetWarningHandler set warning handler function
206 TIFFStripSize returns size of a strip
207 TIFFRawStripSize returns the number of bytes in a raw strip
208 TIFFSwabShort swap bytes of short
209 TIFFSwabLong swap bytes of long
210 TIFFSwabArrayOfShort swap bytes of an array of shorts
211 TIFFSwabArrayOfLong swap bytes of an array of longs
212 TIFFTileRowSize return size of a row in a tile
213 TIFFTileSize return size of a tile
214 TIFFUnRegisterCODEC unregisters the codec
215 TIFFVGetField return tag value in current directory
216 TIFFVGetFieldDefaulted return tag value in current directory
217 TIFFVSetField set a tag's value in the current directory
218 TIFFVStripSize returns the number of bytes in a strip
219 TIFFWarning library warning handler
220 TIFFWriteDirectory write the current directory
221 TIFFWriteEncodedStrip compress and write a strip of data
222 TIFFWriteEncodedTile compress and write a tile of data
223 TIFFWriteRawStrip write a raw strip of data
224 TIFFWriteRawTile write a raw tile of data
225 TIFFWriteScanline write a scanline of data
226 TIFFWriteTile compress and write a tile of data
227 TIFFXYZToRGB perform CIE XYZ to RGB conversion
228 TIFFYCbCrToRGBInit initialize YCbCr to RGB conversion state
229 TIFFYCbCrtoRGB perform YCbCr to RGB conversion
230 .sp
231 Auxiliary functions:
232 _TIFFfree free memory buffer
233 _TIFFmalloc dynamically allocate memory buffer
234 _TIFFmemcmp compare contents of the memory buffers
235 _TIFFmemcpy copy contents of the one buffer to another
236 _TIFFmemset fill memory buffer with a constant byte
237 _TIFFrealloc dynamically reallocate memory buffer
238
239 .fi
240 .SH "TAG USAGE"
241 The table below lists the
242 .SM TIFF
243 tags that are recognized and handled by the library.
244 If no use is indicated in the table, then the library
245 reads and writes the tag, but does not use it internally.
246 Note that some tags are meaningful only when a particular
247 compression scheme is being used; e.g.
248 .I Group3Options
249 is only useful if
250 .I Compression
251 is set to
252 .SM CCITT
253 Group 3 encoding.
254 Tags of this sort are considered
255 .I codec-specific
256 tags and the library does not recognize them except when the
257 .I Compression
258 tag has been previously set to the relevant compression scheme.
259 .sp
260 .nf
261 .ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Value'u+2n +\w'R/W'u+2n
262 \fITag Name\fP \fIValue\fP \fIR/W\fP \fILibrary Use/Notes\fP
263 .sp 5p
264 .nf
265 Artist 315 R/W
266 BadFaxLines 326 R/W
267 BitsPerSample 258 R/W lots
268 CellLength 265 parsed but ignored
269 CellWidth 264 parsed but ignored
270 CleanFaxData 327 R/W
271 ColorMap 320 R/W
272 ColorResponseUnit 300 parsed but ignored
273 Compression 259 R/W choosing codec
274 ConsecutiveBadFaxLines 328 R/W
275 Copyright 33432 R/W
276 DataType 32996 R obsoleted by SampleFormat tag
277 DateTime 306 R/W
278 DocumentName 269 R/W
279 DotRange 336 R/W
280 ExtraSamples 338 R/W lots
281 FaxRecvParams 34908 R/W
282 FaxSubAddress 34909 R/W
283 FaxRecvTime 34910 R/W
284 FillOrder 266 R/W control bit order
285 FreeByteCounts 289 parsed but ignored
286 FreeOffsets 288 parsed but ignored
287 GrayResponseCurve 291 parsed but ignored
288 GrayResponseUnit 290 parsed but ignored
289 Group3Options 292 R/W used by Group 3 codec
290 Group4Options 293 R/W
291 HostComputer 316 R/W
292 ImageDepth 32997 R/W tile/strip calculations
293 ImageDescription 270 R/W
294 ImageLength 257 R/W lots
295 ImageWidth 256 R/W lots
296 InkNames 333 R/W
297 InkSet 332 R/W
298 JPEGTables 347 R/W used by JPEG codec
299 Make 271 R/W
300 Matteing 32995 R obsoleted by ExtraSamples tag
301 MaxSampleValue 281 R/W
302 MinSampleValue 280 R/W
303 Model 272 R/W
304 NewSubFileType 254 R/W called SubFileType in spec
305 NumberOfInks 334 R/W
306 Orientation 274 R/W
307 PageName 285 R/W
308 PageNumber 297 R/W
309 PhotometricInterpretation 262 R/W used by Group 3 and JPEG codecs
310 PlanarConfiguration 284 R/W data i/o
311 Predictor 317 R/W used by LZW and Deflate codecs
312 PrimaryChromacities 319 R/W
313 ReferenceBlackWhite 532 R/W
314 ResolutionUnit 296 R/W used by Group 3 codec
315 RowsPerStrip 278 R/W data i/o
316 SampleFormat 339 R/W
317 SamplesPerPixel 277 R/W lots
318 SMinSampleValue 340 R/W
319 SMaxSampleValue 341 R/W
320 Software 305 R/W
321 StoNits 37439 R/W
322 StripByteCounts 279 R/W data i/o
323 StripOffsets 273 R/W data i/o
324 SubFileType 255 R/W called OSubFileType in spec
325 TargetPrinter 337 R/W
326 Thresholding 263 R/W
327 TileByteCounts 324 R/W data i/o
328 TileDepth 32998 R/W tile/strip calculations
329 TileLength 323 R/W data i/o
330 TileOffsets 324 R/W data i/o
331 TileWidth 322 R/W data i/o
332 TransferFunction 301 R/W
333 WhitePoint 318 R/W
334 XPosition 286 R/W
335 XResolution 282 R/W
336 YCbCrCoefficients 529 R/W used by TIFFRGBAImage support
337 YCbCrPositioning 531 R/W tile/strip size calulcations
338 YCbCrSubsampling 530 R/W
339 YPosition 286 R/W
340 YResolution 283 R/W used by Group 3 codec
341 .SH "PSEUDO TAGS"
342 In addition to the normal
343 .SM TIFF
344 tags the library supports a collection of
345 tags whose values lie in a range outside the valid range of
346 .SM TIFF
347 tags.
348 These tags are termed
349 .I pseud-tags
350 and are used to control various codec-specific functions within the library.
351 The table below summarizes the defined pseudo-tags.
352 .sp
353 .nf
354 .ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Codec'u+2n +\w'R/W'u+2n
355 \fITag Name\fP \fICodec\fP \fIR/W\fP \fILibrary Use/Notes\fP
356 .sp 5p
357 .nf
358 TIFFTAG_FAXMODE G3 R/W general codec operation
359 TIFFTAG_FAXFILLFUNC G3/G4 R/W bitmap fill function
360 TIFFTAG_JPEGQUALITY JPEG R/W compression quality control
361 TIFFTAG_JPEGCOLORMODE JPEG R/W control colorspace conversions
362 TIFFTAG_JPEGTABLESMODE JPEG R/W control contents of \fIJPEGTables\fP tag
363 TIFFTAG_ZIPQUALITY Deflate R/W compression quality level
364 TIFFTAG_PIXARLOGDATAFMT PixarLog R/W user data format
365 TIFFTAG_PIXARLOGQUALITY PixarLog R/W compression quality level
366 TIFFTAG_SGILOGDATAFMT SGILog R/W user data format
367 .fi
368 .TP
369 .B TIFFTAG_FAXMODE
370 Control the operation of the Group 3 codec.
371 Possible values (independent bits that can be combined by
372 or'ing them together) are:
373 FAXMODE_CLASSIC
374 (enable old-style format in which the
375 .SM RTC
376 is written at the end of the last strip),
377 FAXMODE_NORTC
378 (opposite of
379 FAXMODE_CLASSIC;
380 also called
381 FAXMODE_CLASSF),
382 FAXMODE_NOEOL
383 (do not write
384 .SM EOL
385 codes at the start of each row of data),
386 FAXMODE_BYTEALIGN
387 (align each encoded row to an 8-bit boundary),
388 FAXMODE_WORDALIGN
389 (align each encoded row to an 16-bit boundary),
390 The default value is dependent on the compression scheme; this
391 pseudo-tag is used by the various G3 and G4 codecs to share code.
392 .TP
393 .B TIFFTAG_FAXFILLFUNC
394 Control the function used to convert arrays of black and white
395 runs to packed bit arrays.
396 This hook can be used to image decoded scanlines in multi-bit
397 depth rasters (e.g. for display in colormap mode)
398 or for other purposes.
399 The default value is a pointer to a builtin function that images
400 packed bilevel data.
401 .TP
402 .B TIFFTAG_IPTCNEWSPHOTO
403 Tag contaings image metadata per the IPTC newsphoto spec: Headline,
404 captioning, credit, etc... Used by most wire services.
405 .TP
406 .B TIFFTAG_PHOTOSHOP
407 Tag contains Photoshop captioning information and metadata. Photoshop
408 uses in parallel and redundantly alongside IPTCNEWSPHOTO information.
409 .TP
410 .B TIFFTAG_JPEGQUALITY
411 Control the compression quality level used in the baseline algorithm.
412 Note that quality levels are in the range 0-100 with a default value of 75.
413 .TP
414 .B TIFFTAG_JPEGCOLORMODE
415 Control whether or not conversion is done between
416 RGB and YCbCr colorspaces.
417 Possible values are:
418 JPEGCOLORMODE_RAW
419 (do not convert), and
420 JPEGCOLORMODE_RGB
421 (convert to/from RGB)
422 The default value is JPEGCOLORMODE_RAW.
423 .TP
424 .B TIFFTAG_JPEGTABLESMODE
425 Control the information written in the
426 .I JPEGTables
427 tag.
428 Possible values (independent bits that can be combined by
429 or'ing them together) are:
430 JPEGTABLESMODE_QUANT
431 (include quantization tables),
432 and
433 JPEGTABLESMODE_HUFF
434 (include Huffman encoding tables).
435 The default value is JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF.
436 .TP
437 .B TIFFTAG_ZIPQUALITY
438 Control the compression technique used by the Deflate codec.
439 Quality levels are in the range 1-9 with larger numbers yielding better
440 compression at the cost of more computation.
441 The default quality level is 6 which yields a good time-space tradeoff.
442 .TP
443 .B TIFFTAG_PIXARLOGDATAFMT
444 Control the format of user data passed
445 .I in
446 to the PixarLog codec when encoding and passed
447 .I out
448 from when decoding.
449 Possible values are:
450 PIXARLOGDATAFMT_8BIT
451 for 8-bit unsigned pixels,
452 PIXARLOGDATAFMT_8BITABGR
453 for 8-bit unsigned ABGR-ordered pixels,
454 PIXARLOGDATAFMT_11BITLOG
455 for 11-bit log-encoded raw data,
456 PIXARLOGDATAFMT_12BITPICIO
457 for 12-bit PICIO-compatible data,
458 PIXARLOGDATAFMT_16BIT
459 for 16-bit signed samples,
460 and
461 PIXARLOGDATAFMT_FLOAT
462 for 32-bit IEEE floating point samples.
463 .TP
464 .B TIFFTAG_PIXARLOGQUALITY
465 Control the compression technique used by the PixarLog codec.
466 This value is treated identically to TIFFTAG_ZIPQUALITY; see the
467 above description.
468 .TP
469 .B TIFFTAG_SGILOGDATAFMT
470 Control the format of client data passed
471 .I in
472 to the SGILog codec when encoding and passed
473 .I out
474 from when decoding.
475 Possible values are:
476 SGILOGDATAFMT_FLTXYZ
477 for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels,
478 SGILOGDATAFMT_16BITLUV
479 for 16-bit encoded Luv pixels,
480 SGILOGDATAFMT_32BITRAW and SGILOGDATAFMT_24BITRAW
481 for no conversion of data,
482 SGILOGDATAFMT_8BITRGB
483 for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data),
484 SGILOGDATAFMT_FLTY
485 for converting between LogL and 32-bit IEEE floating valued Y pixels,
486 SGILOGDATAFMT_16BITL
487 for 16-bit encoded L pixels,
488 and
489 SGILOGDATAFMT_8BITGRY
490 for returning 8-bit greyscale data
491 (valid only when decoding LogL-encoded data).
492 .SH DIAGNOSTICS
493 All error messages are directed through the
494 .IR TIFFError
495 routine.
496 By default messages are directed to
497 .B stderr
498 in the form:
499 .IR "module: message\en."
500 Warning messages are likewise directed through the
501 .IR TIFFWarning
502 routine.
503 .SH "SEE ALSO"
504 .BR fax2tiff (1),
505 .BR gif2tiff (1),
506 .BR pal2rgb (1),
507 .BR ppm2tiff (1),
508 .BR rgb2ycbcr (1),
509 .BR ras2tiff (1),
510 .BR raw2tiff (1),
511 .BR sgi2tiff (1),
512 .BR tiff2bw (1),
513 .BR tiffdither (1),
514 .BR tiffdump (1),
515 .BR tiffcp (1),
516 .BR tiffcmp (1),
517 .BR tiffgt (1),
518 .BR tiffinfo (1),
519 .BR tiffmedian (1),
520 .BR tiffsplit (1),
521 .BR tiffsv (1).
522 .PP
523 .BR "Tag Image File Format Specification \(em Revision 6.0" ,
524 an Aldus Technical Memorandum.
525 .PP
526 .BR "The Spirit of TIFF Class F" ,
527 an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies.
528 .PP
529 Libtiff library home page:
530 .BR http://www.remotesensing.org/libtiff/
531 .SH BUGS
532 The library does not support multi-sample images
533 where some samples have different bits/sample.
534 .PP
535 The library does not support random access to compressed data
536 that is organized with more than one row per tile or strip.