Method

VipsImagetiffsave

Declaration [src]

int
vips_tiffsave (
  VipsImage* in,
  const char* filename,
  ...
)

Description [src]

Optional arguments:

  • compression: use this VipsForeignTiffCompression
  • Q: %gint quality factor
  • predictor: use this VipsForeignTiffPredictor
  • tile: %gboolean, set TRUE to write a tiled tiff
  • tile_width: %gint for tile size
  • tile_height: %gint for tile size
  • pyramid: %gboolean, write an image pyramid
  • bitdepth: %int, change bit depth to 1,2, or 4 bit
  • miniswhite: %gboolean, write 1-bit images as MINISWHITE
  • resunit: VipsForeignTiffResunit for resolution unit
  • xres: %gdouble horizontal resolution in pixels/mm
  • yres: %gdouble vertical resolution in pixels/mm
  • bigtiff: %gboolean, write a BigTiff file
  • properties: %gboolean, set TRUE to write an IMAGEDESCRIPTION tag
  • region_shrink: VipsRegionShrink How to shrink each 2x2 region.
  • level: %gint, Zstd or Deflate (zlib) compression level
  • lossless: %gboolean, WebP lossless mode
  • depth: VipsForeignDzDepth how deep to make the pyramid
  • subifd: %gboolean write pyr layers as sub-ifds
  • premultiply: %gboolean write premultiplied alpha

Write a VIPS image to a file as TIFF.

If in has the #VIPS_META_PAGE_HEIGHT metadata item, this is assumed to be a “toilet roll” image. It will be written as series of pages, each #VIPS_META_PAGE_HEIGHT pixels high.

Use compression to set the tiff compression. Currently jpeg, packbits, fax4, lzw, none, deflate, webp and zstd are supported. The default is no compression. 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.

XYZ images are automatically saved as libtiff LOGLUV with SGILOG compression. Float LAB images are saved as float CIELAB. Set bitdepth to save as 8-bit CIELAB.

Use Q to set the JPEG compression factor. Default 75.

User level to set the ZSTD (1-22) or Deflate (1-9) compression level. Use lossless to set WEBP lossless mode on. Use Q to set the WEBP compression level.

Use predictor to set the predictor for lzw, deflate and zstd compression. It defaults to #VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL, meaning horizontal differencing. Please refer to the libtiff specifications for further discussion of various predictors.

Set tile to TRUE to write a tiled tiff. By default tiff are written in strips. Use tile_width and tile_height to set the tile size. The defaiult is 128 by 128.

Set pyramid to write the image as a set of images, one per page, of decreasing size. Use region_shrink to set how images will be shrunk: by default each 2x2 block is just averaged, but you can set MODE or MEDIAN as well.

By default, the pyramid stops when the image is small enough to fit in one tile. Use depth to stop when the image fits in one pixel, or to only write a single layer.

Set bitdepth to save 8-bit uchar images as 1, 2 or 4-bit TIFFs. In case of depth 1: Values >128 are written as white, values <=128 as black. Normally vips will write MINISBLACK TIFFs where black is a 0 bit, but if you set miniswhite, it will use 0 for a white bit. Many pre-press applications only work with images which use this sense. miniswhite only affects one-bit images, it does nothing for greyscale images. In case of depth 2: The same holds but values < 64 are written as black. For 64 <= values < 128 they are written as dark grey, for 128 <= values < 192 they are written as light gray and values above are written as white. In case miniswhite is set to true this behavior is inverted. In case of depth 4: values < 16 are written as black, and so on for the lighter shades. In case miniswhite is set to true this behavior is inverted.

Use resunit to override the default resolution unit. The default resolution unit is taken from the header field

VIPS_META_RESOLUTION_UNIT. If this field is not set, then

VIPS defaults to cm.

Use xres and yres to override the default horizontal and vertical resolutions. By default these values are taken from the VIPS image header. libvips resolution is always in pixels per millimetre.

Set bigtiff to attempt to write a bigtiff. Bigtiff is a variant of the TIFF format that allows more than 4GB in a file.

Set properties to write all vips metadata to the IMAGEDESCRIPTION tag as xml. If properties is not set, the value of #VIPS_META_IMAGEDESCRIPTION is used instead.

The value of #VIPS_META_XMP_NAME is written to the XMP tag. #VIPS_META_ORIENTATION (if set) is used to set the value of the orientation tag. #VIPS_META_IPTC (if set) is used to set the value of the IPTC tag.

VIPS_META_PHOTOSHOP_NAME (if set) is used to set the value of the PHOTOSHOP

tag.

By default, pyramid layers are saved as consecutive pages. Set subifd to save pyramid layers as sub-directories of the main image. Setting this option can improve compatibility with formats like OME.

Set premultiply to save with premultiplied alpha. Some programs, such as InDesign, will only work with premultiplied alpha.

See also: vips_tiffload(), vips_image_write_to_file().

This method is not directly available to language bindings.

Parameters

filename

Type: const char*

File to write to.

The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.
...

Type: 

NULL-terminated list of optional named arguments.

Return value

Type: int

0 on success, -1 on error.