### Method

# Vips Image merge

#### Declaration [src]

    int
    vips_merge (
      VipsImage* ref,
      VipsImage* sec,
      VipsImage** out,
      VipsDirection direction,
      int dx,
      int dy,
      ...
    )

#### Description [src]

This operation joins two images left-right (with `ref` on the left) or up-down (with `ref` above) with a smooth seam.

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).

`dx` and `dy` give the displacement of `sec` relative to `ref`, in other words, the vector to get from the origin of `sec` to the origin of `ref`, in other words, `dx` will generally be a negative number.

`mblend` limits the maximum width of the blend area. A value of “-1” means “unlimited”. The two images are blended with a raised cosine.

Pixels with all bands equal to zero are “transparent”, that is, zero pixels in the overlap area do not contribute to the merge. This makes it possible to join non-rectangular images.

Optional arguments

- `mblend`: `gint`, maximum blend size

See also

`vips_mosaic()`, `vips_insert()`.

This method is not directly available to language bindings.

#### Parameters

`sec`

  Type: `VipsImage`

  Secondary 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.

`direction`

  Type: `VipsDirection`

  Horizontal or vertical merge.

`dx`

  Type: `int`

  Displacement of ref from sec.

`dy`

  Type: `int`

  Displacement of ref from sec.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.