1TIFFOpen(3TIFF)                                                TIFFOpen(3TIFF)
2
3
4

NAME

6       TIFFOpen,  TIFFFdOpen, TIFFClientOpen - open a TIFF file for reading or
7       writing
8

SYNOPSIS

10       #include <tiffio.h>
11
12       TIFF* TIFFOpen(const char *filename, const char *mode)
13       TIFF* TIFFFdOpen(const int fd, const char *filename, const char *mode)
14
15       typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
16       typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
17       typedef int (*TIFFCloseProc)(thandle_t);
18       typedef toff_t (*TIFFSizeProc)(thandle_t);
19       typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
20       typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
21
22       TIFF* TIFFClientOpen(const char *filename, const char *mode,  thandle_t
23       clientdata,  TIFFReadWriteProc  readproc,  TIFFReadWriteProc writeproc,
24       TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc  sizeproc,
25       TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc)
26

DESCRIPTION

28       TIFFOpen  opens a TIFF file whose name is filename and returns a handle
29       to be used in subsequent calls to routines in  libtiff.   If  the  open
30       operation  fails,  then zero is returned.  The mode parameter specifies
31       if the file is to be opened for reading (``r''),  writing  (``w''),  or
32       appending  (``a'') and, optionally, whether to override certain default
33       aspects of library operation (see below).  When a file  is  opened  for
34       appending,  existing data will not be touched; instead new data will be
35       written as additional subfiles.  If an  existing  file  is  opened  for
36       writing, all previous data is overwritten.
37
38       If  a  file is opened for reading, the first TIFF directory in the file
39       is automatically read (also  see  TIFFSetDirectory(3TIFF)  for  reading
40       directories  other than the first).  If a file is opened for writing or
41       appending, a default directory is  automatically  created  for  writing
42       subsequent  data.   This directory has all the default values specified
43       in TIFF Revision 6.0: BitsPerSample=1, ThreshHolding=bilevel art  scan,
44       FillOrder=1  (most  significant bit of each data byte is filled first),
45       Orientation=1 (the 0th row represents the visual top of the image,  and
46       the  0th  column  represents  the  visual  left hand side), SamplesPer‐
47       Pixel=1, RowsPerStrip=infinity, ResolutionUnit=2 (inches), and Compres‐
48       sion=1  (no  compression).   To alter these values, or to define values
49       for additional fields, TIFFSetField(3TIFF) must be used.
50
51       TIFFFdOpen is like TIFFOpen except that it opens a TIFF file  given  an
52       open file descriptor fd.  The file's name and mode must reflect that of
53       the open descriptor.  The object associated with  the  file  descriptor
54       must support random access.
55
56       TIFFClientOpen  is like TIFFOpen except that the caller supplies a col‐
57       lection of functions that the library will  use  to  do  UNIX-like  I/O
58       operations.   The  readproc  and writeproc are called to read and write
59       data at the current file position.  seekproc is called  to  change  the
60       current  file  position a la lseek(2).  closeproc is invoked to release
61       any resources associated with an open file.   sizeproc  is  invoked  to
62       obtain  the  size in bytes of a file.  mapproc and unmapproc are called
63       to map and unmap a file's contents in memory; c.f.   mmap(2)  and  mun‐
64       map(2).  The clientdata parameter is an opaque ``handle'' passed to the
65       client-specified routines passed as parameters to TIFFClientOpen.
66

OPTIONS

68       The open mode parameter can include the following flags in addition  to
69       the ``r'', ``w'', and ``a'' flags.  Note however that option flags must
70       follow the read-write-append specification.
71
72       l      When creating a new file force information be written with  Lit‐
73              tle-Endian  byte  order (but see below).  By default the library
74              will create new files using the native CPU byte order.
75
76       b      When creating a new file force information be written with  Big-
77              Endian  byte order (but see below).  By default the library will
78              create new files using the native CPU byte order.
79
80       L      Force image data that is read or written to be treated with bits
81              filled  from Least Significant Bit (LSB) to Most Significant Bit
82              (MSB).  Note that this is the opposite to the  way  the  library
83              has worked from its inception.
84
85       B      Force image data that is read or written to be treated with bits
86              filled from Most Significant Bit (MSB) to Least Significant  Bit
87              (LSB); this is the default.
88
89       H      Force image data that is read or written to be treated with bits
90              filled in the same order as the native CPU.
91
92       M      Enable the use of memory-mapped files for  images  opened  read-
93              only.   If  the underlying system does not support memory-mapped
94              files or if the specific image being opened  cannot  be  memory-
95              mapped then the library will fallback to using the normal system
96              interface for reading information.  By default the library  will
97              attempt to use memory-mapped files.
98
99       m      Disable the use of memory-mapped files.
100
101       C      Enable  the  use  of ``strip chopping'' when reading images that
102              are comprised of a single strip or tile  of  uncompressed  data.
103              Strip chopping is a mechanism by which the library will automat‐
104              ically convert the single-strip image to multiple  strips,  each
105              of  which  has  about 8 Kilobytes of data.  This facility can be
106              useful in reducing the amount of memory used to  read  an  image
107              because  the  library normally reads each strip in its entirety.
108              Strip chopping does however alter the apparent contents  of  the
109              image  because  when an image is divided into multiple strips it
110              looks as though the underlying file contains  multiple  separate
111              strips.   Finally,  note that default handling of strip chopping
112              is a compile-time configuration parameter.  The  default  behav‐
113              iour, for backwards compatibility, is to enable strip chopping.
114
115       c      Disable the use of strip chopping when reading images.
116
117       h      Read  TIFF  header  only, do not load the first image directory.
118              That could be useful in case of the broken first  directory.  We
119              can open the file and proceed to the other directories.
120
121       4      ClassicTIFF for creating a file (default)
122
123       8      BigTIFF for creating a file.
124
125       D      Enable  use  of deferred strip/tile offset/bytecount array load‐
126              ing. They will be loaded the first time they  are  accessed  to.
127              This  loading  will be done in its entirety unless the O flag is
128              also specified.
129
130       O      On-demand loading of values of the  strip/tile  offset/bytecount
131              arrays,  limited  to  the requested strip/tile, instead of whole
132              array loading (implies D)
133

BYTE ORDER

135       The TIFF specification (all versions)  states  that  compliant  readers
136       must  be capable of reading images written in either byte order.  None‐
137       theless some software that claims to support the reading of TIFF images
138       is  incapable  of  reading  images  in anything but the native CPU byte
139       order on which the software was  written.   (Especially  notorious  are
140       applications  written  to run on Intel-based machines.)  By default the
141       library will create new files with the native byte-order of the CPU  on
142       which  the application is run.  This ensures optimal performance and is
143       portable to any application that conforms to  the  TIFF  specification.
144       To  force  the library to use a specific byte-order when creating a new
145       file the ``b'' and ``l'' option flags may be included in  the  call  to
146       open a file; for example, ``wb'' or ``wl''.
147

RETURN VALUES

149       Upon  successful  completion  TIFFOpen,  TIFFFdOpen, and TIFFClientOpen
150       return a TIFF pointer.  Otherwise, NULL is returned.
151

DIAGNOSTICS

153       All error messages are directed to the TIFFError(3TIFF) routine.  Like‐
154       wise, warning messages are directed to the TIFFWarning(3TIFF) routine.
155
156       "%s":  Bad  mode.   The  specified  mode parameter was not one of ``r''
157       (read), ``w'' (write), or ``a'' (append).
158
159       %s: Cannot open.  TIFFOpen() was unable to open the specified  filename
160       for read/writing.
161
162       Cannot  read  TIFF  header.  An error occurred while attempting to read
163       the header information.
164
165       Error writing TIFF header.  An error occurred while writing the default
166       header information for a new file.
167
168       Not  a  TIFF file, bad magic number %d (0x%x).  The magic number in the
169       header was not (hex) 0x4d4d or (hex) 0x4949.
170
171       Not a TIFF file, bad version number %d (0x%x).  The  version  field  in
172       the header was not 42 (decimal).
173
174       Cannot  append  to file that has opposite byte ordering.  A file with a
175       byte ordering opposite to the  native  byte  ordering  of  the  current
176       machine  was opened for appending (``a'').  This is a limitation of the
177       library.
178

SEE ALSO

180       libtiff(3TIFF), TIFFClose(3TIFF)
181
182
183
184libtiff                          July 1, 2005                  TIFFOpen(3TIFF)
Impressum