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

TIFFOpen

kusano 7d535a
NAME
kusano 7d535a
SYNOPSIS
kusano 7d535a
DESCRIPTION
kusano 7d535a
OPTIONS
kusano 7d535a
BYTE ORDER
kusano 7d535a
RETURN VALUES
kusano 7d535a
DIAGNOSTICS
kusano 7d535a
SEE ALSO
kusano 7d535a
kusano 7d535a

kusano 7d535a
kusano 7d535a

NAME

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

TIFFOpen, TIFFFdOpen, TIFFClientOpen − open a

kusano 7d535a
<small>TIFF</small> file for reading or writing

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

SYNOPSIS

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

#include <tiffio.h>

kusano 7d535a
kusano 7d535a

TIFF* TIFFOpen(const char *filename,

kusano 7d535a
const char *mode)
kusano 7d535a
TIFF* TIFFFdOpen(const int fd, const char
kusano 7d535a
*filename, const char
kusano 7d535a
*mode)

kusano 7d535a
kusano 7d535a

typedef tsize_t (*TIFFReadWriteProc)(thandle_t,

kusano 7d535a
tdata_t, tsize_t);
kusano 7d535a
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
kusano 7d535a
typedef int (*TIFFCloseProc)(thandle_t);
kusano 7d535a
typedef toff_t (*TIFFSizeProc)(thandle_t);
kusano 7d535a
typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*,
kusano 7d535a
toff_t*);
kusano 7d535a
typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t,
kusano 7d535a
toff_t);

kusano 7d535a
kusano 7d535a

TIFF* TIFFClientOpen(const char

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

DESCRIPTION

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

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

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

kusano 7d535a
kusano 7d535a

If a file is opened for reading, the first

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

kusano 7d535a
kusano 7d535a

TIFFFdOpen is like TIFFOpen except that it

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

kusano 7d535a
kusano 7d535a

TIFFClientOpen is like TIFFOpen except that

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

OPTIONS

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

The open mode parameter can include the following flags

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="5" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

l

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

When creating a new file force information be written

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

b

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

When creating a new file force information be written

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

L

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Force image data that is read or written to be treated

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

B

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Force image data that is read or written to be treated

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

H

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Force image data that is read or written to be treated

kusano 7d535a
with bits filled in the same order as the native
kusano 7d535a
<small>CPU.</small>

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

M

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Enable the use of memory-mapped files for images opened

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

m

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Disable the use of memory-mapped files.

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

C

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Enable the use of ‘‘strip

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

c

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Disable the use of strip chopping when reading

kusano 7d535a
images.

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

h

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Read TIFF header only, do not load the first image

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

BYTE ORDER

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

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

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

RETURN VALUES

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Upon successful completion TIFFOpen,

kusano 7d535a
TIFFFdOpen, and TIFFClientOpen return a
kusano 7d535a
<small>TIFF</small> pointer. Otherwise, NULL is
kusano 7d535a
returned.

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

DIAGNOSTICS

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

All error messages are directed to the

kusano 7d535a
TIFFError(3TIFF) routine. Likewise, warning messages
kusano 7d535a
are directed to the TIFFWarning(3TIFF) routine.

kusano 7d535a
kusano 7d535a

"%s": Bad mode. The specified

kusano 7d535a
mode parameter was not one of
kusano 7d535a
‘‘r’’ (read),
kusano 7d535a
‘‘w’’ (write), or
kusano 7d535a
‘‘a’’ (append).

kusano 7d535a
kusano 7d535a

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

kusano 7d535a
open the specified filename for read/writing.

kusano 7d535a
kusano 7d535a

Cannot read TIFF header. An error occurred while

kusano 7d535a
attempting to read the header information.

kusano 7d535a
kusano 7d535a

Error writing TIFF header. An error occurred while

kusano 7d535a
writing the default header information for a new file.

kusano 7d535a
kusano 7d535a

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

kusano 7d535a
magic number in the header was not (hex) 0x4d4d or (hex)
kusano 7d535a
0x4949.

kusano 7d535a
kusano 7d535a

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

kusano 7d535a
version field in the header was not 42 (decimal).

kusano 7d535a
kusano 7d535a

Cannot append to file that has opposite byte

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

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

SEE ALSO

kusano 7d535a
kusano 7d535a
kusano 7d535a
       cols="2" cellspacing="0" cellpadding="0">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

libtiff(3TIFF), TIFFClose(3TIFF)

kusano 7d535a
kusano 7d535a
kusano 7d535a

kusano 7d535a
kusano 7d535a