1 .\" $Id: TIFFOpen.3tiff,v 1.2 2005/07/01 12:36:22 dron 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 TIFFOpen 3TIFF "July 1, 2005" "libtiff"
28 TIFFOpen, TIFFFdOpen, TIFFClientOpen \- open a
30 file for reading or writing
32 .B "#include <tiffio.h>"
34 .BI "TIFF* TIFFOpen(const char *" filename ", const char *" mode ")"
36 .BI "TIFF* TIFFFdOpen(const int " fd ", const char *" filename ", const char *" mode ")"
38 .B "typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);"
40 .B "typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);"
42 .B "typedef int (*TIFFCloseProc)(thandle_t);"
44 .B "typedef toff_t (*TIFFSizeProc)(thandle_t);"
46 .B "typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);"
48 .B "typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);"
50 .BI "TIFF* TIFFClientOpen(const char *" filename ", const char *" mode ", thandle_t " clientdata ", TIFFReadWriteProc " readproc ", TIFFReadWriteProc " writeproc ", TIFFSeekProc " seekproc ", TIFFCloseProc " closeproc ", TIFFSizeProc " sizeproc ", TIFFMapFileProc " mapproc ", TIFFUnmapFileProc " unmapproc ")"
57 and returns a handle to be used in subsequent calls to routines in
59 If the open operation fails, then zero is returned.
62 parameter specifies if the file is to be opened for reading (``r''),
63 writing (``w''), or appending (``a'') and, optionally, whether
64 to override certain default aspects of library operation (see below).
65 When a file is opened for appending, existing data will not
66 be touched; instead new data will be written as additional subfiles.
67 If an existing file is opened for writing, all previous data is
70 If a file is opened for reading, the first
72 directory in the file is automatically read
74 .IR TIFFSetDirectory (3TIFF)
75 for reading directories other than the first).
76 If a file is opened for writing or appending, a default directory
77 is automatically created for writing subsequent data.
78 This directory has all the default values specified in
82 .IR ThreshHolding "=bilevel art scan,"
84 (most significant bit of each data byte is filled first),
86 (the 0th row represents the visual top of the image, and the 0th
87 column represents the visual left hand side),
88 .IR SamplesPerPixel =1,
89 .IR RowsPerStrip =infinity,
94 To alter these values, or to define values for additional fields,
95 .IR TIFFSetField (3TIFF)
101 except that it opens a
103 file given an open file descriptor
105 The file's name and mode must reflect that of the open descriptor.
106 The object associated with the file descriptor
107 .BR "must support random access" .
112 except that the caller supplies a collection of functions that the
113 library will use to do \s-1UNIX\s+1-like I/O operations.
118 are called to read and write data at the current file position.
120 is called to change the current file position a la
123 is invoked to release any resources associated with an open file.
125 is invoked to obtain the size in bytes of a file.
129 are called to map and unmap a file's contents in memory; c.f.
135 parameter is an opaque ``handle'' passed to the client-specified
136 routines passed as parameters to
139 The open mode parameter can include the following flags in
140 addition to the ``r'', ``w'', and ``a'' flags.
141 Note however that option flags must follow the read-write-append
145 When creating a new file force information be written with
146 Little-Endian byte order (but see below).
147 By default the library will create new files using the native
152 When creating a new file force information be written with
153 Big-Endian byte order (but see below).
154 By default the library will create new files using the native
159 Force image data that is read or written to be treated with
160 bits filled from Least Significant Bit (\s-1LSB\s+1) to
161 Most Significant Bit (\s-1MSB\s+1).
162 Note that this is the opposite to the way the library has
163 worked from its inception.
166 Force image data that is read or written to be treated with
167 bits filled from Most Significant Bit (\s-1MSB\s+1) to
168 Least Significant Bit (\s-1LSB\s+1); this is the default.
171 Force image data that is read or written to be treated with
172 bits filled in the same order as the native
176 Enable the use of memory-mapped files for images opened read-only.
177 If the underlying system does not support memory-mapped files
178 or if the specific image being opened cannot be memory-mapped
179 then the library will fallback to using the normal system interface
180 for reading information.
181 By default the library will attempt to use memory-mapped files.
184 Disable the use of memory-mapped files.
187 Enable the use of ``strip chopping'' when reading images
188 that are comprised of a single strip or tile of uncompressed data.
189 Strip chopping is a mechanism by which the library will automatically
190 convert the single-strip image to multiple strips,
191 each of which has about 8 Kilobytes of data.
192 This facility can be useful in reducing the amount of memory used
193 to read an image because the library normally reads each strip
195 Strip chopping does however alter the apparent contents of the
196 image because when an image is divided into multiple strips it
197 looks as though the underlying file contains multiple separate
199 Finally, note that default handling of strip chopping is a compile-time
200 configuration parameter.
201 The default behaviour, for backwards compatibility, is to enable
205 Disable the use of strip chopping when reading images.
208 Read TIFF header only, do not load the first image directory. That could be
209 useful in case of the broken first directory. We can open the file and proceed
210 to the other directories.
214 specification (\fBall versions\fP) states that compliant readers
215 .IR "must be capable of reading images written in either byte order" .
216 Nonetheless some software that claims to support the reading of
218 images is incapable of reading images in anything but the native
220 byte order on which the software was written.
221 (Especially notorious
222 are applications written to run on Intel-based machines.)
223 By default the library will create new files with the native
226 on which the application is run.
227 This ensures optimal performance and is portable to any application
228 that conforms to the TIFF specification.
229 To force the library to use a specific byte-order when creating
230 a new file the ``b'' and ``l'' option flags may be included in
231 the call to open a file; for example, ``wb'' or ``wl''.
233 Upon successful completion
241 Otherwise, NULL is returned.
243 All error messages are directed to the
244 .IR TIFFError (3TIFF)
246 Likewise, warning messages are directed to the
247 .IR TIFFWarning (3TIFF)
250 \fB"%s": Bad mode\fP.
253 parameter was not one of ``r'' (read), ``w'' (write), or ``a'' (append).
255 .BR "%s: Cannot open" .
257 was unable to open the specified filename for read/writing.
259 .BR "Cannot read TIFF header" .
260 An error occurred while attempting to read the header information.
262 .BR "Error writing TIFF header" .
263 An error occurred while writing the default header information
266 .BR "Not a TIFF file, bad magic number %d (0x%x)" .
267 The magic number in the header was not (hex)
268 0x4d4d or (hex) 0x4949.
270 .BR "Not a TIFF file, bad version number %d (0x%x)" .
271 The version field in the header was not 42 (decimal).
273 .BR "Cannot append to file that has opposite byte ordering" .
274 A file with a byte ordering opposite to the native byte
275 ordering of the current machine was opened for appending (``a'').
276 This is a limitation of the library.
279 .IR TIFFClose (3TIFF)