Vips.Image.subtract

### Method

# Vips Imagesubtract

#### Declaration [src]

    int
    vips_subtract (
      VipsImage* in1,
      VipsImage* in2,
      VipsImage** out,
      ...
    )

#### Description [src]

This operation calculates `in1` - `in2` and writes the result to `out`.

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), then the following table is used to determine the output type:

## `vips_subtract()` type promotion

input type | output type
--- | ---
uchar | short
char | short
ushort | int
short | int
uint | int
int | int
float | float
double | double
complex | complex
double complex | double complex

In other words, the output type is just large enough to hold the whole range of possible values.

See also

`vips_add()`, `vips_linear()`.

This method is not directly available to language bindings.

#### Parameters

`in2`

  Type: `VipsImage`

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

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.