summaryrefslogtreecommitdiff
path: root/man/libtiff.3t
blob: 411a4659db00c559a4dd72326975100524b52db0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
.\" $Header: /usr/people/sam/tiff/man/RCS/libtiff.3t,v 1.23 1996/08/01 19:10:20 sam Exp $
.\"
.\" Copyright (c) 1988-1995 Sam Leffler
.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and 
.\" its documentation for any purpose is hereby granted without fee, provided
.\" that (i) the above copyright notices and this permission notice appear in
.\" all copies of the software and related documentation, and (ii) the names of
.\" Sam Leffler and Silicon Graphics may not be used in any advertising or
.\" publicity relating to the software without the specific, prior written
.\" permission of Sam Leffler and Silicon Graphics.
.\" 
.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
.\" 
.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
.\" OF THIS SOFTWARE.
.\"
.if n .po 0
.TH INTRO 3T "August 1, 1996"
.SH NAME
libtiff \- introduction to
.IR libtiff ,
a library for reading and writing
.SM TIFF
files
.SH SYNOPSIS
.B "#include <tiffio.h>"
.br
cc file.c
.B -ltiff
.SH DESCRIPTION
.I libtiff
is a library for reading and writing data files encoded with the
.I "Tag Image File"
format, Revision 6.0 (or revision 5.0 or revision 4.0).
This file format is suitable for archiving multi-color and
monochromatic image data.
.PP
The library supports several compression algorithms, as indicated
by the
.I Compression
field, including:
no compression (1),
.SM CCITT
1D Huffman compression (2),
.SM CCITT
Group 3 Facsimile compression (3),
.SM CCITT
Group 4 Facsimile compression (4),
Lempel-Ziv & Welch compression (5),
baseline JPEG compression (7),
word-aligned 1D Huffman compression (32771),
and
PackBits compression (32773).
In addition, several nonstandard compression algorithms are supported:
the 4-bit compression algorithm used
by the
.I ThunderScan
program (32809) (decompression only),
NeXT's 2-bit compression algorithm (32766) (decompression only), and
an experimental LZ-style algorithm known as Deflate (32946).
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 (\c
.SM MSB\c
) to Least Significant Bit (\c
.SM LSB\c
) or
.SM LSB
to
.SM MSB.
Finally, the library does not support files in which the
.IR BitsPerSample ,
.IR Compression ,
.IR MinSampleValue ,
or
.IR MaxSampleValue
fields are defined differently on a per-sample basis
(in Rev. 6.0 the
.I Compression
tag is not defined on a per-sample basis, so this is immaterial).
.SH "DATA TYPES"
The 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
.SM TIFF
format.
The following typedefs are exposed to users either through
function definitions or through parameters passed through the
varargs interfaces.
.in +.5i
.sp 5p
.ta +\w'typedef unsigned <\fIthing\fP> uint32;    'u
.nf
typedef unsigned short uint16;	16-bit unsigned integer
typedef unsigned <\fIthing\fP> uint32;	32-bit unsigned integer
.sp 5p
typedef unsigned int ttag_t;	directory tag
typedef uint16 tdir_t;	directory index
typedef uint16 tsample_t;	sample number
typedef uint32 tstrip_t;	strip number
typedef uint32 ttile_t;	tile number
typedef int32 tsize_t;	i/o size in bytes
typedef void* tdata_t;	image data ref
typedef void* thandle_t;	client data handle
typedef int32 toff_t;	file offset
.fi
.sp 5p
.in -.5i
Note that
.IR tstrip_t ,
.IR ttile_t ,
and
.I tsize_t
are constrained to be no more than 32-bit quantities by
32-bit fields they are stored in in the
.SM TIFF
image.
Likewise
.I tsample_t
is limited by the 16-bit field used to store the
.I SamplesPerPixel
tag.
.I tdir_t
constrains the maximum number of
.SM IFDs
that may appear in an image and may be an arbitrary size (w/o penalty). 
.I ttag_t
must be either int, unsigned int, pointer, or double because
the library uses a varargs interface and
.SM "ANSI C"
restricts the type of the parameter before an ellipsis to be a
promoted type.
.I 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.
Finally, note that user-specified data references are
passed as opaque handles and only cast at the lowest layers where
their type is presumed.
.SH "LIST OF ROUTINES"
The following routines are part of the library.
Consult specific manual pages for details on their operation.
The manual page names listed below are for systems
where the full function names can not be encoded in the filesystem;
on most systems doing ``man function-name'' will work.
.sp 5p
.nf
.ta \w'TIFFWriteEncodedStrip'u+2n +\w'Appears on Page'u+2n
\fIName\fP	\fIAppears on Page\fP	\fIDescription\fP
.sp 5p
TIFFCheckTile	tile.3t	very x,y,z,sample is within image
TIFFClientOpen	open.3t	open a file for reading or writing
TIFFClose	close.3t	close an open file
TIFFComputeStrip	strip.3t	return strip containing y,sample
TIFFComputeTile	tile.3t	return tile containing x,y,z,sample
TIFFCurrentDirectory	query.3t	return index of current directory
TIFFCurrentRow	query.3t	return index of current scanline
TIFFCurrentStrip	query.3t	return index of current strip
TIFFCurrentTile	query.3t	return index of current tile
TIFFError	error.3t	library error handler
TIFFFdOpen	open.3t	open a file for reading or writing
TIFFFileName	query.3t	return name of open file
TIFFFileno	query.3t	return open file descriptor
TIFFFlush	flush.3t	flush all pending writes
TIFFFlushData	flush.3t	flush pending data writes
TIFFGetBitRevTable	swab.3t	return bit reversal table
TIFFGetField	getfield.3t	return tag value in current directory
TIFFGetFieldDefaulted	getfield.3t	return tag value in current directory
TIFFGetMode	query.3t	return open file mode
TIFFGetVersion	query.3t	return library version string
TIFFIsTiled	query.3t	return true if image data is tiled
TIFFIsByteSwapped	query.3t	return true if image data is byte-swapped
TIFFNumberOfStrips	strip.3t	return number of strips in an image
TIFFNumberOfTiles	tile.3t	return number of tiles in an image
TIFFOpen	open.3t	open a file for reading or writing
TIFFPrintDirectory	print.3t	print description of the current directory
TIFFReadBufferSetup	rdbuf.3t	specify i/o buffer for reading
TIFFReadDirectory	readdir.3t	read the next directory
TIFFReadEncodedStrip	rdestrip.3t	read and decode a strip of data
TIFFReadEncodedTile	rdetile.3t	read and decode a tile of data
TIFFReadRawStrip	rdrstrip.3t	read a raw strip of data
TIFFReadRawTile	rdrtile.3t	read a raw tile of data
TIFFReadRGBAImage	rdimage.3t	read an image into a fixed format raster
TIFFReadScanline	readline.3t	read and decode a row of data
TIFFReadTile	readtile.3t	read and decode a tile of data
TIFFReverseBits	swab.3t	reverse bits in an array of bytes
TIFFRGBAImageBegin	rgbaimage.3t	setup decoder state for TIFFRGBAImageGet
TIFFRGBAImageEnd	rgbaimage.3t	release TIFFRGBAImage decoder state
TIFFRGBAImageGet	rgbaimage.3t	read and decode an image
TIFFRGBAImageOK	rgbaimage.3t	is image readable by TIFFRGBAImageGet
TIFFScanlineSize	size.3t	return size of a scanline
TIFFSetDirectory	setdir.3t	set the current directory
TIFFSetSubDirectory	setdir.3t	set the current directory
TIFFSetErrorHandler	error.3t	set error handler function
TIFFSetField	setfield.3t	set a tag's value in the current directory
TIFFSetWarningHandler	error.3t	set warning handler function
TIFFStripSize	size.3t	return size of a strip
TIFFSwabShort	swab.3t	swap bytes of short
TIFFSwabLong	swab.3t	swap bytes of long
TIFFSwabArrayOfShort	swab.3t	swap bytes of an array of shorts
TIFFSwabArrayOfLong	swab.3t	swap bytes of an array of longs
TIFFTileRowSize	size.3t	return size of a row in a tile
TIFFTileSize	size.3t	return size of a tile
TIFFVGetField	getfield.3t	return tag value in current directory
TIFFVGetFieldDefaulted	getfield.3t	return tag value in current directory
TIFFVSetField	setfield.3t	set a tag's value in the current directory
TIFFWarning	warning.3t	library warning handler
TIFFWriteDirectory	writedir.3t	write the current directory
TIFFWriteEncodedStrip	wrestrip.3t	compress and write a strip of data
TIFFWriteEncodedTile	wretile.3t	compress and write a tile of data
TIFFWriteRawStrip	wrrstrip.3t	write a raw strip of data
TIFFWriteRawTile	wrrtile.3t	write a raw tile of data
TIFFWriteScanline	writeline.3t	write a scanline of data
TIFFWriteTile	wrrtile.3t	compress and write a tile of data
.fi
.SH "TAG USAGE"
The table below lists the
.SM TIFF
tags that are recognized and handled by the library.
If no use is indicated in the table, then the library
reads and writes the tag, but does not use it internally.
Note that some tags are meaningful only when a particular
compression scheme is being used; e.g.
.I Group3Options
is only useful if 
.I Compression
is set to
.SM CCITT
Group 3 encoding.
Tags of this sort are considered
.I codec-specific
tags and the library does not recognize them except when the
.I Compression
tag has been previously set to the relevant compression scheme.
.sp 5p
.nf
.ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Value'u+2n +\w'R/W'u+2n
\fITag Name\fP	\fIValue\fP	\fIR/W\fP	\fILibrary Use/Notes\fP
.sp 5p
.nf
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
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
.SH "PSEUDO TAGS"
In addition to the normal
.SM TIFF
tags the library supports a collection of 
tags whose values lie in a range outside the valid range of 
.SM TIFF
tags.
These tags are termed
.I pseud-tags
and are used to control various codec-specific functions within the library.
The table below summarizes the defined pseudo-tags.
.sp 5p
.nf
.ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Codec'u+2n +\w'R/W'u+2n
\fITag Name\fP	\fICodec\fP	\fIR/W\fP	\fILibrary Use/Notes\fP
.sp 5p
.nf
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 \fIJPEGTables\fP tag
.fi
.TP
.B TIFFTAG_FAXMODE
Control the operation of the Group 3 codec.
Possible values (independent bits that can be combined by
or'ing them together) are:
FAXMODE_CLASSIC
(enable old-style format in which the
.SM RTC
is written at the end of the last strip),
FAXMODE_NORTC
(opposite of 
FAXMODE_CLASSIC;
also called
FAXMODE_CLASSF),
FAXMODE_NOEOL
(do not write 
.SM EOL
codes at the start of each row of data),
FAXMODE_BYTEALIGN
(align each encoded row to an 8-bit boundary),
FAXMODE_WORDALIGN
(align each encoded row to an 16-bit boundary),
The default value is dependent on the compression scheme; this
pseudo-tag is used by the various G3 and G4 codecs to share code.
.TP
.B TIFFTAG_FAXFILLFUNC
Control 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 (e.g. for display in colormap mode)
or for other purposes.
The default value is a pointer to a builtin function that images
packed bilevel data.
.TP
.B TIFFTAG_JPEGQUALITY
Control 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.
.TP
.B TIFFTAG_JPEGCOLORMODE
Control 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.
.TP
.B TIFFTAG_JPEGTABLESMODE
Control the information written in the 
.I JPEGTables
tag.
Possible values (independent bits that can be combined by
or'ing them together) are:
JPEGTABLESMODE_QUANT
(include quantization tables),
and
JPEGTABLESMODE_HUFF
(include Huffman encoding tables).
The default value is JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF.
.SH DIAGNOSTICS
All error messages are directed through the
.IR TIFFError
routine.
By default messages are directed to
.B stderr
in the form:
.IR "module: message\en."
Warning messages are likewise directed through the
.IR TIFFWarning
routine.
.SH "SEE ALSO"
.IR fax2tiff (1),
.IR gif2tiff (1),
.IR pal2rgb (1),
.IR ppm2tiff (1),
.IR rgb2ycbcr (1),
.IR ras2tiff (1),
.IR sgi2tiff (1),
.IR tiff2bw (1),
.IR tiffdither (1),
.IR tiffdump (1),
.IR tiffcp (1),
.IR tiffcmp (1),
.IR tiffgt (1),
.IR tiffinfo (1),
.IR tiffmedian (1),
.IR tiffsplit (1),
.IR tiffsv (1),
.PP
.IR "Tag Image File Format Specification \(em Revision 6.0" ,
an Aldus Technical Memorandum.
.PP
.IR "The Spirit of TIFF Class F" ,
an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies.
.SH BUGS
The library does not support multi-sample images
where some samples have different bits/sample.
.PP
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 directory's contents.