### Method

# Vips Image magicksave

#### Declaration [src]

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

#### Description [src]

Write an image using libMagick.

Use `quality` to set the quality factor. Default 0.

Use `format` to explicitly set the save format, for example, “BMP”. Otherwise the format is guessed from the filename suffix.

If `optimize_gif_frames` is set, GIF frames are cropped to the smallest size while preserving the results of the GIF animation. This takes some time for computation but saves some time on encoding and produces smaller files in some cases.

If `optimize_gif_transparency` is set, pixels that don’t change the image through animation are made transparent. This takes some time for computation but saves some time on encoding and produces smaller files in some cases.

`bitdepth` specifies the number of bits per pixel. The image will be quantized and dithered if the value is within the valid range (1 to 8).

Optional arguments

- `quality`: `gint`, quality factor
- `format`: `gchararray`, format to save as
- `optimize_gif_frames`: `gboolean`, apply GIF frames optimization
- `optimize_gif_transparency`: `gboolean`, apply GIF transparency optimization
- `bitdepth`: `gint`, number of bits per pixel

See also

`vips_magicksave_buffer()`, `vips_magickload()`.

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.