summaryrefslogtreecommitdiff
path: root/tiff/html/man/TIFFOpen.3tiff.html
blob: 6bc85d84e0deb4b11ba8318f6ee1e86aa0e3850d (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
<!-- Creator     : groff version 1.18.1 -->
<!-- CreationDate: Fri Jul 13 17:43:15 2007 -->
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta name="Content-Style" content="text/css">
<title>TIFFOpen</title>
</head>
<body>

<h1 align=center>TIFFOpen</h1>
<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#OPTIONS">OPTIONS</a><br>
<a href="#BYTE ORDER">BYTE ORDER</a><br>
<a href="#RETURN VALUES">RETURN VALUES</a><br>
<a href="#DIAGNOSTICS">DIAGNOSTICS</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>

<hr>
<a name="NAME"></a>
<h2>NAME</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p>TIFFOpen, TIFFFdOpen, TIFFClientOpen &minus; open a
<small>TIFF</small> file for reading or writing</p>
</td>
</table>
<a name="SYNOPSIS"></a>
<h2>SYNOPSIS</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p><b>#include &lt;tiffio.h&gt;</b></p>
<!-- INDENTATION -->
<p><b>TIFF* TIFFOpen(const char *</b><i>filename</i><b>,
const char *</b><i>mode</i><b>)<br>
TIFF* TIFFFdOpen(const int</b> <i>fd</i><b>, const char
*</b><i>filename</i><b>, const char
*</b><i>mode</i><b>)</b></p>
<!-- INDENTATION -->
<p><b>typedef tsize_t (*TIFFReadWriteProc)(thandle_t,
tdata_t, tsize_t);<br>
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);<br>
typedef int (*TIFFCloseProc)(thandle_t);<br>
typedef toff_t (*TIFFSizeProc)(thandle_t);<br>
typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*,
toff_t*);<br>
typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t,
toff_t);</b></p>
<!-- INDENTATION -->
<p><b>TIFF* TIFFClientOpen(const char
*</b><i>filename</i><b>, const char *</b><i>mode</i><b>,
thandle_t</b> <i>clientdata</i><b>, TIFFReadWriteProc</b>
<i>readproc</i><b>, TIFFReadWriteProc</b>
<i>writeproc</i><b>, TIFFSeekProc</b> <i>seekproc</i><b>,
TIFFCloseProc</b> <i>closeproc</i><b>, TIFFSizeProc</b>
<i>sizeproc</i><b>, TIFFMapFileProc</b> <i>mapproc</i><b>,
TIFFUnmapFileProc</b> <i>unmapproc</i><b>)</b></p>
</td>
</table>
<a name="DESCRIPTION"></a>
<h2>DESCRIPTION</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p><i>TIFFOpen</i> opens a <small>TIFF</small> file whose
name is <i>filename</i> and returns a handle to be used in
subsequent calls to routines in <i>libtiff</i>. If the open
operation fails, then zero is returned. The <i>mode</i>
parameter specifies if the file is to be opened for reading
(&lsquo;&lsquo;r&rsquo;&rsquo;), writing
(&lsquo;&lsquo;w&rsquo;&rsquo;), or appending
(&lsquo;&lsquo;a&rsquo;&rsquo;) and, optionally, whether to
override certain default aspects of library operation (see
below). When a file is opened for appending, existing data
will not be touched; instead new data will be written as
additional subfiles. If an existing file is opened for
writing, all previous data is overwritten.</p>
<!-- INDENTATION -->
<p>If a file is opened for reading, the first
<small>TIFF</small> directory in the file is automatically
read (also see <i>TIFFSetDirectory</i>(3TIFF) for reading
directories other than the first). If a file is opened for
writing or appending, a default directory is automatically
created for writing subsequent data. This directory has all
the default values specified in <small>TIFF</small> Revision
6.0: <i>BitsPerSample</i>=1, <i>ThreshHolding</i>=bilevel
art scan, <i>FillOrder</i>=1 (most significant bit of each
data byte is filled first), <i>Orientation</i>=1 (the 0th
row represents the visual top of the image, and the 0th
column represents the visual left hand side),
<i>SamplesPerPixel</i>=1, <i>RowsPerStrip</i>=infinity,
<i>ResolutionUnit</i>=2 (inches), and <i>Compression</i>=1
(no compression). To alter these values, or to define values
for additional fields, <i>TIFFSetField</i>(3TIFF) must be
used.</p>
<!-- INDENTATION -->
<p><i>TIFFFdOpen</i> is like <i>TIFFOpen</i> except that it
opens a <small>TIFF</small> file given an open file
descriptor <i>fd</i>. The file&rsquo;s name and mode must
reflect that of the open descriptor. The object associated
with the file descriptor <b>must support random
access</b>.</p>
<!-- INDENTATION -->
<p><i>TIFFClientOpen</i> is like <i>TIFFOpen</i> except that
the caller supplies a collection of functions that the
library will use to do <small>UNIX</small> -like I/O
operations. The <i>readproc</i> and <i>writeproc</i> are
called to read and write data at the current file position.
<i>seekproc</i> is called to change the current file
position a la <i>lseek</i>(2). <i>closeproc</i> is invoked
to release any resources associated with an open file.
<i>sizeproc</i> is invoked to obtain the size in bytes of a
file. <i>mapproc</i> and <i>unmapproc</i> are called to map
and unmap a file&rsquo;s contents in memory; c.f.
<i>mmap</i>(2) and <i>munmap</i>(2). The <i>clientdata</i>
parameter is an opaque &lsquo;&lsquo;handle&rsquo;&rsquo;
passed to the client-specified routines passed as parameters
to <i>TIFFClientOpen</i>.</p>
</td>
</table>
<a name="OPTIONS"></a>
<h2>OPTIONS</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p>The open mode parameter can include the following flags
in addition to the &lsquo;&lsquo;r&rsquo;&rsquo;,
&lsquo;&lsquo;w&rsquo;&rsquo;, and
&lsquo;&lsquo;a&rsquo;&rsquo; flags. Note however that
option flags must follow the read-write-append
specification.</p>
</td>
</table>
<!-- TABS -->
<table width="100%" border=0 rules="none" frame="void"
       cols="5" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>l</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>When creating a new file force information be written
with Little-Endian byte order (but see below). By default
the library will create new files using the native
<small>CPU</small> byte order.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>b</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>When creating a new file force information be written
with Big-Endian byte order (but see below). By default the
library will create new files using the native
<small>CPU</small> byte order.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>L</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Force image data that is read or written to be treated
with bits filled from Least Significant Bit (
<small>LSB</small> ) to Most Significant Bit (
<small>MSB</small> ). Note that this is the opposite to the
way the library has worked from its inception.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>B</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Force image data that is read or written to be treated
with bits filled from Most Significant Bit (
<small>MSB</small> ) to Least Significant Bit (
<small>LSB</small> ); this is the default.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>H</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Force image data that is read or written to be treated
with bits filled in the same order as the native
<small>CPU.</small></p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>M</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Enable the use of memory-mapped files for images opened
read-only. If the underlying system does not support
memory-mapped files or if the specific image being opened
cannot be memory-mapped then the library will fallback to
using the normal system interface for reading information.
By default the library will attempt to use memory-mapped
files.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>m</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Disable the use of memory-mapped files.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>C</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Enable the use of &lsquo;&lsquo;strip
chopping&rsquo;&rsquo; when reading images that are
comprised of a single strip or tile of uncompressed data.
Strip chopping is a mechanism by which the library will
automatically convert the single-strip image to multiple
strips, each of which has about 8 Kilobytes of data. This
facility can be useful in reducing the amount of memory used
to read an image because the library normally reads each
strip in its entirety. Strip chopping does however alter the
apparent contents of the image because when an image is
divided into multiple strips it looks as though the
underlying file contains multiple separate strips. Finally,
note that default handling of strip chopping is a
compile-time configuration parameter. The default behaviour,
for backwards compatibility, is to enable strip
chopping.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>c</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Disable the use of strip chopping when reading
images.</p>
</td>
<td width="0%">
</td>
<tr valign="top" align="left">
<td width="10%"></td>
<td width="2%">

<p><b>h</b></p>
</td>
<td width="6%"></td>
<td width="80%">

<p>Read TIFF header only, do not load the first image
directory. That could be useful in case of the broken first
directory. We can open the file and proceed to the other
directories.</p>
</td>
<td width="0%">
</td>
</table>
<a name="BYTE ORDER"></a>
<h2>BYTE ORDER</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p>The <small>TIFF</small> specification (<b>all
versions</b>) states that compliant readers <i>must be
capable of reading images written in either byte order</i>.
Nonetheless some software that claims to support the reading
of <small>TIFF</small> images is incapable of reading images
in anything but the native <small>CPU</small> byte order on
which the software was written. (Especially notorious are
applications written to run on Intel-based machines.) By
default the library will create new files with the native
byte-order of the <small>CPU</small> on which the
application is run. This ensures optimal performance and is
portable to any application that conforms to the TIFF
specification. To force the library to use a specific
byte-order when creating a new file the
&lsquo;&lsquo;b&rsquo;&rsquo; and
&lsquo;&lsquo;l&rsquo;&rsquo; option flags may be included
in the call to open a file; for example,
&lsquo;&lsquo;wb&rsquo;&rsquo; or
&lsquo;&lsquo;wl&rsquo;&rsquo;.</p>
</td>
</table>
<a name="RETURN VALUES"></a>
<h2>RETURN VALUES</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p>Upon successful completion <i>TIFFOpen</i>,
<i>TIFFFdOpen</i>, and <i>TIFFClientOpen</i> return a
<small>TIFF</small> pointer. Otherwise, NULL is
returned.</p>
</td>
</table>
<a name="DIAGNOSTICS"></a>
<h2>DIAGNOSTICS</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p>All error messages are directed to the
<i>TIFFError</i>(3TIFF) routine. Likewise, warning messages
are directed to the <i>TIFFWarning</i>(3TIFF) routine.</p>
<!-- INDENTATION -->
<p><b>&quot;%s&quot;: Bad mode</b>. The specified
<i>mode</i> parameter was not one of
&lsquo;&lsquo;r&rsquo;&rsquo; (read),
&lsquo;&lsquo;w&rsquo;&rsquo; (write), or
&lsquo;&lsquo;a&rsquo;&rsquo; (append).</p>
<!-- INDENTATION -->
<p><b>%s: Cannot open</b>. <i>TIFFOpen</i>() was unable to
open the specified filename for read/writing.</p>
<!-- INDENTATION -->
<p><b>Cannot read TIFF header</b>. An error occurred while
attempting to read the header information.</p>
<!-- INDENTATION -->
<p><b>Error writing TIFF header</b>. An error occurred while
writing the default header information for a new file.</p>
<!-- INDENTATION -->
<p><b>Not a TIFF file, bad magic number %d (0x%x)</b>. The
magic number in the header was not (hex) 0x4d4d or (hex)
0x4949.</p>
<!-- INDENTATION -->
<p><b>Not a TIFF file, bad version number %d (0x%x)</b>. The
version field in the header was not 42 (decimal).</p>
<!-- INDENTATION -->
<p><b>Cannot append to file that has opposite byte
ordering</b>. A file with a byte ordering opposite to the
native byte ordering of the current machine was opened for
appending (&lsquo;&lsquo;a&rsquo;&rsquo;). This is a
limitation of the library.</p>
</td>
</table>
<a name="SEE ALSO"></a>
<h2>SEE ALSO</h2>
<!-- INDENTATION -->
<table width="100%" border=0 rules="none" frame="void"
       cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="8%"></td>
<td width="91%">
<p><i>libtiff</i>(3TIFF), <i>TIFFClose</i>(3TIFF)</p>
</td>
</table>
<hr>
</body>
</html>