roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
<meta content="groff -Thtml, see www.gnu.org" name="generator">
roentgen b75cab
<meta content="text/css" name="Content-Style">
roentgen b75cab
<title>TIFFOpen</title>
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

TIFFOpen

roentgen b75cab
NAME
roentgen b75cab
SYNOPSIS
roentgen b75cab
DESCRIPTION
roentgen b75cab
OPTIONS
roentgen b75cab
BYTE ORDER
roentgen b75cab
RETURN VALUES
roentgen b75cab
DIAGNOSTICS
roentgen b75cab
SEE ALSO
roentgen b75cab
roentgen b75cab

roentgen b75cab
roentgen b75cab

NAME

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

TIFFOpen, TIFFFdOpen, TIFFClientOpen − open a

roentgen b75cab
<small>TIFF</small> file for reading or writing

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

SYNOPSIS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

#include <tiffio.h>

roentgen b75cab
roentgen b75cab

TIFF* TIFFOpen(const char *filename,

roentgen b75cab
const char *mode)
roentgen b75cab
TIFF* TIFFFdOpen(const int fd, const char
roentgen b75cab
*filename, const char
roentgen b75cab
*mode)

roentgen b75cab
roentgen b75cab

typedef tsize_t (*TIFFReadWriteProc)(thandle_t,

roentgen b75cab
tdata_t, tsize_t);
roentgen b75cab
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
roentgen b75cab
typedef int (*TIFFCloseProc)(thandle_t);
roentgen b75cab
typedef toff_t (*TIFFSizeProc)(thandle_t);
roentgen b75cab
typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*,
roentgen b75cab
toff_t*);
roentgen b75cab
typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t,
roentgen b75cab
toff_t);

roentgen b75cab
roentgen b75cab

TIFF* TIFFClientOpen(const char

roentgen b75cab
*filename, const char *mode,
roentgen b75cab
thandle_t clientdata, TIFFReadWriteProc
roentgen b75cab
readproc, TIFFReadWriteProc
roentgen b75cab
writeproc, TIFFSeekProc seekproc,
roentgen b75cab
TIFFCloseProc closeproc, TIFFSizeProc
roentgen b75cab
sizeproc, TIFFMapFileProc mapproc,
roentgen b75cab
TIFFUnmapFileProc unmapproc)

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

DESCRIPTION

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

TIFFOpen opens a <small>TIFF</small> file whose

roentgen b75cab
name is filename and returns a handle to be used in
roentgen b75cab
subsequent calls to routines in libtiff. If the open
roentgen b75cab
operation fails, then zero is returned. The mode
roentgen b75cab
parameter specifies if the file is to be opened for reading
roentgen b75cab
(‘‘r’’), writing
roentgen b75cab
(‘‘w’’), or appending
roentgen b75cab
(‘‘a’’) and, optionally, whether to
roentgen b75cab
override certain default aspects of library operation (see
roentgen b75cab
below). When a file is opened for appending, existing data
roentgen b75cab
will not be touched; instead new data will be written as
roentgen b75cab
additional subfiles. If an existing file is opened for
roentgen b75cab
writing, all previous data is overwritten.

roentgen b75cab
roentgen b75cab

If a file is opened for reading, the first

roentgen b75cab
<small>TIFF</small> directory in the file is automatically
roentgen b75cab
read (also see TIFFSetDirectory(3TIFF) for reading
roentgen b75cab
directories other than the first). If a file is opened for
roentgen b75cab
writing or appending, a default directory is automatically
roentgen b75cab
created for writing subsequent data. This directory has all
roentgen b75cab
the default values specified in <small>TIFF</small> Revision
roentgen b75cab
6.0: BitsPerSample=1, ThreshHolding=bilevel
roentgen b75cab
art scan, FillOrder=1 (most significant bit of each
roentgen b75cab
data byte is filled first), Orientation=1 (the 0th
roentgen b75cab
row represents the visual top of the image, and the 0th
roentgen b75cab
column represents the visual left hand side),
roentgen b75cab
SamplesPerPixel=1, RowsPerStrip=infinity,
roentgen b75cab
ResolutionUnit=2 (inches), and Compression=1
roentgen b75cab
(no compression). To alter these values, or to define values
roentgen b75cab
for additional fields, TIFFSetField(3TIFF) must be
roentgen b75cab
used.

roentgen b75cab
roentgen b75cab

TIFFFdOpen is like TIFFOpen except that it

roentgen b75cab
opens a <small>TIFF</small> file given an open file
roentgen b75cab
descriptor fd. The file’s name and mode must
roentgen b75cab
reflect that of the open descriptor. The object associated
roentgen b75cab
with the file descriptor must support random
roentgen b75cab
access.

roentgen b75cab
roentgen b75cab

TIFFClientOpen is like TIFFOpen except that

roentgen b75cab
the caller supplies a collection of functions that the
roentgen b75cab
library will use to do <small>UNIX</small> -like I/O
roentgen b75cab
operations. The readproc and writeproc are
roentgen b75cab
called to read and write data at the current file position.
roentgen b75cab
seekproc is called to change the current file
roentgen b75cab
position a la lseek(2). closeproc is invoked
roentgen b75cab
to release any resources associated with an open file.
roentgen b75cab
sizeproc is invoked to obtain the size in bytes of a
roentgen b75cab
file. mapproc and unmapproc are called to map
roentgen b75cab
and unmap a file’s contents in memory; c.f.
roentgen b75cab
mmap(2) and munmap(2). The clientdata
roentgen b75cab
parameter is an opaque ‘‘handle’’
roentgen b75cab
passed to the client-specified routines passed as parameters
roentgen b75cab
to TIFFClientOpen.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

OPTIONS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

The open mode parameter can include the following flags

roentgen b75cab
in addition to the ‘‘r’’,
roentgen b75cab
‘‘w’’, and
roentgen b75cab
‘‘a’’ flags. Note however that
roentgen b75cab
option flags must follow the read-write-append
roentgen b75cab
specification.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="5" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

l

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

When creating a new file force information be written

roentgen b75cab
with Little-Endian byte order (but see below). By default
roentgen b75cab
the library will create new files using the native
roentgen b75cab
<small>CPU</small> byte order.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

b

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

When creating a new file force information be written

roentgen b75cab
with Big-Endian byte order (but see below). By default the
roentgen b75cab
library will create new files using the native
roentgen b75cab
<small>CPU</small> byte order.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

L

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Force image data that is read or written to be treated

roentgen b75cab
with bits filled from Least Significant Bit (
roentgen b75cab
<small>LSB</small> ) to Most Significant Bit (
roentgen b75cab
<small>MSB</small> ). Note that this is the opposite to the
roentgen b75cab
way the library has worked from its inception.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

B

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Force image data that is read or written to be treated

roentgen b75cab
with bits filled from Most Significant Bit (
roentgen b75cab
<small>MSB</small> ) to Least Significant Bit (
roentgen b75cab
<small>LSB</small> ); this is the default.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

H

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Force image data that is read or written to be treated

roentgen b75cab
with bits filled in the same order as the native
roentgen b75cab
<small>CPU.</small>

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

M

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Enable the use of memory-mapped files for images opened

roentgen b75cab
read-only. If the underlying system does not support
roentgen b75cab
memory-mapped files or if the specific image being opened
roentgen b75cab
cannot be memory-mapped then the library will fallback to
roentgen b75cab
using the normal system interface for reading information.
roentgen b75cab
By default the library will attempt to use memory-mapped
roentgen b75cab
files.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

m

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Disable the use of memory-mapped files.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

C

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Enable the use of ‘‘strip

roentgen b75cab
chopping’’ when reading images that are
roentgen b75cab
comprised of a single strip or tile of uncompressed data.
roentgen b75cab
Strip chopping is a mechanism by which the library will
roentgen b75cab
automatically convert the single-strip image to multiple
roentgen b75cab
strips, each of which has about 8 Kilobytes of data. This
roentgen b75cab
facility can be useful in reducing the amount of memory used
roentgen b75cab
to read an image because the library normally reads each
roentgen b75cab
strip in its entirety. Strip chopping does however alter the
roentgen b75cab
apparent contents of the image because when an image is
roentgen b75cab
divided into multiple strips it looks as though the
roentgen b75cab
underlying file contains multiple separate strips. Finally,
roentgen b75cab
note that default handling of strip chopping is a
roentgen b75cab
compile-time configuration parameter. The default behaviour,
roentgen b75cab
for backwards compatibility, is to enable strip
roentgen b75cab
chopping.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

c

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Disable the use of strip chopping when reading

roentgen b75cab
images.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

h

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Read TIFF header only, do not load the first image

roentgen b75cab
directory. That could be useful in case of the broken first
roentgen b75cab
directory. We can open the file and proceed to the other
roentgen b75cab
directories.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

BYTE ORDER

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

The <small>TIFF</small> specification (all

roentgen b75cab
versions) states that compliant readers must be
roentgen b75cab
capable of reading images written in either byte order.
roentgen b75cab
Nonetheless some software that claims to support the reading
roentgen b75cab
of <small>TIFF</small> images is incapable of reading images
roentgen b75cab
in anything but the native <small>CPU</small> byte order on
roentgen b75cab
which the software was written. (Especially notorious are
roentgen b75cab
applications written to run on Intel-based machines.) By
roentgen b75cab
default the library will create new files with the native
roentgen b75cab
byte-order of the <small>CPU</small> on which the
roentgen b75cab
application is run. This ensures optimal performance and is
roentgen b75cab
portable to any application that conforms to the TIFF
roentgen b75cab
specification. To force the library to use a specific
roentgen b75cab
byte-order when creating a new file the
roentgen b75cab
‘‘b’’ and
roentgen b75cab
‘‘l’’ option flags may be included
roentgen b75cab
in the call to open a file; for example,
roentgen b75cab
‘‘wb’’ or
roentgen b75cab
‘‘wl’’.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

RETURN VALUES

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

Upon successful completion TIFFOpen,

roentgen b75cab
TIFFFdOpen, and TIFFClientOpen return a
roentgen b75cab
<small>TIFF</small> pointer. Otherwise, NULL is
roentgen b75cab
returned.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

DIAGNOSTICS

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

All error messages are directed to the

roentgen b75cab
TIFFError(3TIFF) routine. Likewise, warning messages
roentgen b75cab
are directed to the TIFFWarning(3TIFF) routine.

roentgen b75cab
roentgen b75cab

"%s": Bad mode. The specified

roentgen b75cab
mode parameter was not one of
roentgen b75cab
‘‘r’’ (read),
roentgen b75cab
‘‘w’’ (write), or
roentgen b75cab
‘‘a’’ (append).

roentgen b75cab
roentgen b75cab

%s: Cannot open. TIFFOpen() was unable to

roentgen b75cab
open the specified filename for read/writing.

roentgen b75cab
roentgen b75cab

Cannot read TIFF header. An error occurred while

roentgen b75cab
attempting to read the header information.

roentgen b75cab
roentgen b75cab

Error writing TIFF header. An error occurred while

roentgen b75cab
writing the default header information for a new file.

roentgen b75cab
roentgen b75cab

Not a TIFF file, bad magic number %d (0x%x). The

roentgen b75cab
magic number in the header was not (hex) 0x4d4d or (hex)
roentgen b75cab
0x4949.

roentgen b75cab
roentgen b75cab

Not a TIFF file, bad version number %d (0x%x). The

roentgen b75cab
version field in the header was not 42 (decimal).

roentgen b75cab
roentgen b75cab

Cannot append to file that has opposite byte

roentgen b75cab
ordering. A file with a byte ordering opposite to the
roentgen b75cab
native byte ordering of the current machine was opened for
roentgen b75cab
appending (‘‘a’’). This is a
roentgen b75cab
limitation of the library.

roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

SEE ALSO

roentgen b75cab
roentgen b75cab
roentgen b75cab
       cols="2" cellspacing="0" cellpadding="0">
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

libtiff(3TIFF), TIFFClose(3TIFF)

roentgen b75cab
roentgen b75cab
roentgen b75cab

roentgen b75cab
roentgen b75cab