SYNOPSIS
#include <vips/vips.h>int im_tiff2vips( const char *filename, IMAGE *out )
int im_vips2tiff( IMAGE *in, const char *filename )
DESCRIPTION
im_tiff2vips(3) reads the tiff image in filename, and writes the image out in VIPS format. It is a full baseline TIFF 6 reader, with extensions for tiled images, multipage images, LAB colour space, pyramidal images and JPEG compression.You can embed options in the filename. They have the form:
filename.tif:<page-number>
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.
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
"ccittfax4" - CCITT Group 4 fax encoding
"lzw" - Lempel-Ziv compression
"jpeg" compression can be followed by a ":" character and a JPEG quality level; "lzw" and "deflate" can be followed by a ":" and predictor value. The default compression type is "none", the default JPEG quality factor is 75.
Predictor is not set by default. There are three predictor values recognised
at the moment (2007, July): 1 is no prediction, 2 is a horizontal differencing
and 3 is a floating point predictor. Refer to the libtiff specifications for
further discussion of various predictors. In short, predictor helps to better
compress image, especially in case of digital photos or scanned images and bit
depths > 8. Try it to find whether it works for your images.
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 pixels per centimetre
"res_inch" - output resolution unit is pixels per inch
The default resolution unit is taken from the header field "resolution-unit" (IM_META_RESOLUTION_UNIT in C). If this field is not set, then VIPS defaults to cm.
This may be overridden by the <resolution> option. 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.
EXAMPLES
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.
COPYRIGHT
Hey, you want this? You have it!