Blame html/man/TIFFOpen.3tiff.html

Packit 994f1a
Packit 994f1a
Packit 994f1a
<html>
Packit 994f1a
<head>
Packit 994f1a
<meta name="generator" content="groff -Thtml, see www.gnu.org">
Packit 994f1a
<meta name="Content-Style" content="text/css">
Packit 994f1a
<title>TIFFOpen</title>
Packit 994f1a
</head>
Packit 994f1a
<body>
Packit 994f1a
Packit 994f1a

TIFFOpen

Packit 994f1a
NAME
Packit 994f1a
SYNOPSIS
Packit 994f1a
DESCRIPTION
Packit 994f1a
OPTIONS
Packit 994f1a
BYTE ORDER
Packit 994f1a
RETURN VALUES
Packit 994f1a
DIAGNOSTICS
Packit 994f1a
SEE ALSO
Packit 994f1a
Packit 994f1a

Packit 994f1a
Packit 994f1a

NAME

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

TIFFOpen, TIFFFdOpen, TIFFClientOpen − open a

Packit 994f1a
<small>TIFF</small> file for reading or writing

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

SYNOPSIS

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

#include <tiffio.h>

Packit 994f1a
Packit 994f1a

TIFF* TIFFOpen(const char *filename,

Packit 994f1a
const char *mode)
Packit 994f1a
TIFF* TIFFFdOpen(const int fd, const char
Packit 994f1a
*filename, const char
Packit 994f1a
*mode)

Packit 994f1a
Packit 994f1a

typedef tsize_t (*TIFFReadWriteProc)(thandle_t,

Packit 994f1a
tdata_t, tsize_t);
Packit 994f1a
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
Packit 994f1a
typedef int (*TIFFCloseProc)(thandle_t);
Packit 994f1a
typedef toff_t (*TIFFSizeProc)(thandle_t);
Packit 994f1a
typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*,
Packit 994f1a
toff_t*);
Packit 994f1a
typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t,
Packit 994f1a
toff_t);

Packit 994f1a
Packit 994f1a

TIFF* TIFFClientOpen(const char

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

DESCRIPTION

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

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

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

Packit 994f1a
Packit 994f1a

If a file is opened for reading, the first

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

Packit 994f1a
Packit 994f1a

TIFFFdOpen is like TIFFOpen except that it

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

Packit 994f1a
Packit 994f1a

TIFFClientOpen is like TIFFOpen except that

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

OPTIONS

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

The open mode parameter can include the following flags

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="5" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

l

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

When creating a new file force information be written

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

b

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

When creating a new file force information be written

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

L

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Force image data that is read or written to be treated

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

B

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Force image data that is read or written to be treated

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

H

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Force image data that is read or written to be treated

Packit 994f1a
with bits filled in the same order as the native
Packit 994f1a
<small>CPU.</small>

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

M

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Enable the use of memory-mapped files for images opened

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

m

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Disable the use of memory-mapped files.

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

C

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Enable the use of ‘‘strip

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

c

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Disable the use of strip chopping when reading

Packit 994f1a
images.

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

h

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Read TIFF header only, do not load the first image

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

BYTE ORDER

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

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

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

RETURN VALUES

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

Upon successful completion TIFFOpen,

Packit 994f1a
TIFFFdOpen, and TIFFClientOpen return a
Packit 994f1a
<small>TIFF</small> pointer. Otherwise, NULL is
Packit 994f1a
returned.

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

DIAGNOSTICS

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

All error messages are directed to the

Packit 994f1a
TIFFError(3TIFF) routine. Likewise, warning messages
Packit 994f1a
are directed to the TIFFWarning(3TIFF) routine.

Packit 994f1a
Packit 994f1a

"%s": Bad mode. The specified

Packit 994f1a
mode parameter was not one of
Packit 994f1a
‘‘r’’ (read),
Packit 994f1a
‘‘w’’ (write), or
Packit 994f1a
‘‘a’’ (append).

Packit 994f1a
Packit 994f1a

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

Packit 994f1a
open the specified filename for read/writing.

Packit 994f1a
Packit 994f1a

Cannot read TIFF header. An error occurred while

Packit 994f1a
attempting to read the header information.

Packit 994f1a
Packit 994f1a

Error writing TIFF header. An error occurred while

Packit 994f1a
writing the default header information for a new file.

Packit 994f1a
Packit 994f1a

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

Packit 994f1a
magic number in the header was not (hex) 0x4d4d or (hex)
Packit 994f1a
0x4949.

Packit 994f1a
Packit 994f1a

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

Packit 994f1a
version field in the header was not 42 (decimal).

Packit 994f1a
Packit 994f1a

Cannot append to file that has opposite byte

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

Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

SEE ALSO

Packit 994f1a
Packit 994f1a
Packit 994f1a
       cols="2" cellspacing="0" cellpadding="0">
Packit 994f1a
Packit 994f1a
Packit 994f1a
Packit 994f1a

libtiff(3TIFF), TIFFClose(3TIFF)

Packit 994f1a
Packit 994f1a
Packit 994f1a

Packit 994f1a
</body>
Packit 994f1a
</html>