### Function

# Vips Image sum

#### Declaration [src]

    int
    vips_sum (
      VipsImage** in,
      VipsImage** out,
      int n,
      ...
    )

#### Description [src]

This operation sums all images in `in` and writes the result to `out`.

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

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

The 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_sum()` type promotion

input type | output type
--- | ---
uchar | uint
char | int
ushort | uint
short | int
uint | uint
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()`.

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.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.