Vips.Image.heifsave

### Method

# Vips Imageheifsave

#### Declaration [src]

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

#### Description [src]

Write a VIPS image to a file in HEIF format.

Use `Q` to set the compression factor. Default 50, which seems to be roughly what the iphone uses. Q 30 gives about the same quality as JPEG Q 75.

Set `lossless` `TRUE` to switch to lossless compression.

Use `compression` to set the compression format e.g. HEVC, AVC, AV1 to use. It defaults to AV1 if the target filename ends with “.avif”, otherwise HEVC.

Use `effort` to control the CPU effort spent improving compression. This is currently only applicable to AV1 encoders. Defaults to 4, 0 is fastest, 9 is slowest.

Chroma subsampling is normally automatically disabled for Q >= 90. You can force the subsampling mode with `subsample_mode`.

Use `bitdepth` to set the bitdepth of the output file. HEIC supports at least 8, 10 and 12 bits; other codecs may support more or fewer options.

Use `encoder` to set the encode library to use, e.g. aom, SVT-AV1, rav1e etc.

Use `tune` to pass a set of tuning parameters to the encoder, see the libheif documentation.

Optional arguments

- `Q`: `gint`, quality factor
- `bitdepth`: `gint`, set write bit depth to 8, 10, or 12 bits
- `lossless`: `gboolean`, enable lossless encoding
- `compression`: `VipsForeignHeifCompression`, write with this compression
- `effort`: `gint`, encoding effort
- `subsample_mode`: `VipsForeignSubsample`, chroma subsampling mode
- `encoder`: `VipsForeignHeifEncoder`, select encoder to use
- `tune`: `gchararray`, encoder tuning parameters

See also

`vips_image_write_to_file()`, `vips_heifload()`.

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.