Method

VipsImagewebpsave

Declaration [src]

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

Description [src]

Optional arguments:

  • Q: %gint, quality factor
  • lossless: %gboolean, enables lossless compression
  • preset: VipsForeignWebpPreset, choose lossy compression preset
  • smart_subsample: %gboolean, enables high quality chroma subsampling
  • near_lossless: %gboolean, preprocess in lossless mode (controlled by Q)
  • alpha_q: %gint, set alpha quality in lossless mode
  • effort: %gint, level of CPU effort to reduce file size
  • min_size: %gboolean, minimise size
  • mixed: %gboolean, allow both lossy and lossless encoding
  • kmin: %gint, minimum number of frames between keyframes
  • kmax: %gint, maximum number of frames between keyframes
  • strip: %gboolean, remove all metadata from image
  • profile: %gchararray, filename of ICC profile to attach

Write an image to a file in WebP format.

By default, images are saved in lossy format, with Q giving the WebP quality factor. It has the range 0 - 100, with the default 75.

Use preset to hint the image type to the lossy compressor. The default is

VIPS_FOREIGN_WEBP_PRESET_DEFAULT.

Set smart_subsample to enable high quality chroma subsampling.

Use alpha_q to set the quality for the alpha channel in lossy mode. It has the range 1 - 100, with the default 100.

Use effort to control how much CPU time to spend attempting to reduce file size. A higher value means more effort and therefore CPU time should be spent. It has the range 0-6 and a default value of 4.

Set lossless to use lossless compression, or combine near_lossless with Q 80, 60, 40 or 20 to apply increasing amounts of preprocessing which improves the near-lossless compression ratio by up to 50%.

For animated webp output, min_size will try to optimize for minimum size.

For animated webp output, kmax sets the maximum number of frames between keyframes. Setting 0 means only keyframes. kmin sets the minimum number of frames between frames. Setting 0 means no keyframes. By default, keyframes are disabled.

For animated webp output, mixed tries to improve the file size by mixing both lossy and lossless encoding.

Use profile to give the name of a profile to be embedded in the file. This does not affect the pixels which are written, just the way they are tagged. See vips_profile_load() for details on profile naming.

Use the metadata items loop and delay to set the number of loops for the animation and the frame delays.

The writer will attach ICC, EXIF and XMP metadata, unless strip is set to TRUE.

See also: vips_webpload(), vips_image_write_to_file().

This method is not directly available to language bindings.

Parameters

filename const char*
 

File to write to.

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

NULL-terminated list of optional named arguments.

Return value

Returns: int
 

0 on success, -1 on error.