### Method

# Vips Image insert

#### Declaration [src]

    int
    vips_insert (
      VipsImage* main,
      VipsImage* sub,
      VipsImage** out,
      int x,
      int y,
      ...
    )

#### Description [src]

Insert `sub` into `main` at position `x`, `y`.

Normally `out` shows the whole of `main`. If `expand` is `TRUE` then `out` is made large enough to hold all of `main` and `sub`. Any areas of `out` not coming from either `main` or `sub` are set to `background` (default 0).

If `sub` overlaps `main`, `sub` will appear on top of `main`.

If the number of bands differs, one of the images must have one band. In this case, an n-band image is formed from the one-band image by joining n copies of the one-band image together, and then the two n-band images are operated upon.

The two input images are cast up to the smallest common type (see table Smallest common format in arithmetic).

Optional arguments

- `expand`: `gdouble`, expand output to hold whole of both images
- `background`: `VipsArrayDouble`, colour for new pixels

See also

`vips_join()`, `vips_embed()`, `vips_extract_area()`.

This method is not directly available to language bindings.

#### Parameters

`sub`

  Type: `VipsImage`

  Small image.

  The data is owned by the caller of the method.

`out`

  Type: `VipsImage`

  Output image.

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

`x`

  Type: `int`

  Left position of `sub`.

`y`

  Type: `int`

  Top position of `sub`.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.