Vips.Image.math2

### Method

# Vips Imagemath2

#### Declaration [src]

    int
    vips_math2 (
      VipsImage* left,
      VipsImage* right,
      VipsImage** out,
      VipsOperationMath2 math2,
      ...
    )

#### Description [src]

This operation calculates a 2-ary maths operation on a pair of images and writes the result to `out`. The images may have any non-complex format. `out` is float except in the case that either of `left` or `right` are double, in which case `out` is also double.

It detects division by zero, setting those pixels to zero in the output. Beware: it does this silently!

If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.

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 format (see table Smallest common format in arithmetic), and that format is the result type.

See also

`vips_math2_const()`.

This method is not directly available to language bindings.

#### Parameters

`right`

  Type: `VipsImage`

  Right-hand input `VipsImage`.

  The data is owned by the caller of the method.

`out`

  Type: `VipsImage`

  Output `VipsImage`.

  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.

`math2`

  Type: `VipsOperationMath2`

  Math operation to perform.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.