### Function

# Vips Image composite

#### Declaration [src]

    int
    vips_composite (
      VipsImage** in,
      VipsImage** out,
      int n,
      int* mode,
      ...
    )

#### Description [src]

Composite an array of images together.

Images are placed in a stack, with `in`[0] at the bottom and `in`[`n` - 1] at the top. Pixels are blended together working from the bottom upwards, with the blend mode at each step being set by the corresponding `VipsBlendMode` in `mode`.

Images are transformed to a compositing space before processing. This is `VIPS_INTERPRETATION_sRGB`, `VIPS_INTERPRETATION_B_W`, `VIPS_INTERPRETATION_RGB16`, or `VIPS_INTERPRETATION_GREY16` by default, depending on how many bands and bits the input images have. You can select any other space, such as `VIPS_INTERPRETATION_LAB` or `VIPS_INTERPRETATION_scRGB`.

The output image is in the compositing space. It will always be `VIPS_FORMAT_FLOAT` unless one of the inputs is `VIPS_FORMAT_DOUBLE`, in which case the output will be double as well.

Complex images are not supported.

The output image will always have an alpha band. A solid alpha is added to any input missing an alpha.

The images do not need to match in size or format. The output image is always the size of `in`[0], with other images being positioned with the `x` and `y` parameters and clipped against that rectangle.

Image are normally treated as unpremultiplied, so this operation can be used directly on PNG images. If your images have been through `vips_premultiply()`, set `premultiplied`.

Optional arguments

- `compositing_space`: `VipsInterpretation` to composite in
- `premultiplied`: `gboolean`, images are already premultiplied
- `x`: `VipsArrayInt`, array of (`n` - 1) x coordinates
- `y`: `VipsArrayInt`, array of (`n` - 1) y coordinates

See also

`vips_insert()`.

This function is not directly available to language bindings.

#### Parameters

`in`

  Type: An array of `VipsImage*`

  Array of input images.

  The length of the array is specified in the `n` argument.
  The data is owned by the caller of the function.

`out`

  Type: `VipsImage`

  Output image.

  The argument will be set by the function.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.

`n`

  Type: `int`

  Number of input images.

`mode`

  Type: `int*`

  Array of (`n` - 1) `VipsBlendMode`.

  The data is owned by the caller of the function.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.