int im_tiff2vips( const char *filename, IMAGE *out )
int im_tiff2vips_header( const char *filename, IMAGE *out )
int im_vips2tiff( IMAGE *in, const char *filename )
You can embed options in the filename. They have the form:
filename.tif:<page-number>,<broken>
page-number lets you read a particular page out of a multipage TIFF file. For example:
"fred.tif:12"
will read page 12 (numbering from page zero) from the TIFF image.
broken turns on backwards compatibility for tiled TIFF files written with versions of VIPS before 7.9.3. Without this flag you'll see problems in edge tiles. For example:
"fred.tif:,broken"
will read fred.tif, with the old and broken edge tile code.
Use im_istifftiled(3) and im_istiffpyramid(3) to find the TIFF image type before calling.
im_tiff2vips_header(3) reads just the header information from the TIFF file. You can't read any pixels!
im_vips2tiff(3) reads the image in and writes a TIFF file to the specified filename. The filename may include an optional mode string, following a ':' character. For example, "fred.tif" would write a default TIFF file (flat, strips, no compression). Writing to "fred.tif:deflate,tile:64x64" would write a ZIP-coded image, split into 64 by 64 pixel tiles.
The mode string has the following syntax:
<compression>,<layout>,<multi-res>,<format>,<resolution>,<icc>
where <compression> is one of:
"none" - no compression
"jpeg" - JPEG compression
"deflate" - ZIP (deflate) compression
"packbits" - TIFF packbits compression
"lzw" - Lempel-Ziv compression
"jpeg" compression can be followed by a ":" character and a JPEG quality level. The default compression type is "none", the default JPEG quality factor is 75.
JPEG compression is a good lossy compressor for photographs, packbits is good for 1-bit images, and deflate is the best lossless compression TIFF can do. LZW has patent problems, and is no longer recommended.
<layout> is one of:
"strip" - strip layout
"tile" - tiled layout
"tile" layout can be followed by a ":" character and the horizontal and vertical tile size, separated by a "x" character. The default layout is "strip", and the default tile size is 128 by 128 pixels.
<multi-res> is one of:
"flat" - single image
"pyramid" - many images arranged in a pyramid
The default multi-res mode is "flat".
<format> is one of:
"manybit"
- don't bit-reduce images
"onebit" - one band 8 bit images are saved as 1 bit
The default format is "multibit".
<resolution> is one of:
"res_cm"
- output resolution unit is piexls per centimetre
"res_inch" - output resolution unit is piexls per inch
The default format is "res_cm". The unit can optionally be followed by a ":" character and the horizontal and vertical resolution, separated by a "x" character. You can have a single number with no "x" and set the horizontal and vertical resolutions together. The default unit is cm, and the default resolution is taken from the VIPS header.
<icc> is the filename of an ICC
profile to embed in the TIFF file
The TIFF reader and writer are based on Sam Leffler's TIFF library, and the IJG JPEG coder.
The call:
im_vips2tiff fred.v fred.tif
Writes a striped, uncompressed TIFF image. Almost anything should be able to read this.
im_vips2tiff fred.v fred.tif:jpeg,tile,pyramid
Writes a tiled JPEG pyramid image. Although VIPS tries to follow the TIFF specification carefully, you may have trouble reading this on any system other than VIPS.
im_vips2tiff fred.v fred.tif:jpeg:25,tile:64x64
Writes a highly compressed JPEG image, with a tile size of 64 by 64 pixels.
im_vips2tiff fred.v fred.tif:,tile
Writes an uncompressed tiled image.
im_vips2tiff fred.v fred.tif:packbits,tile,,onebit
Writes a tiled one bit TIFF image (provided fred.v is a one band 8 bit image) compressed with packbits.
im_vips2tiff fred.v fred.tif:,,,,res_inch:300
Writes fred.v as a tiff file, with the resolution in the tiff header set to 300 dpi.