Vips.Image.ifthenelse

### Method

# Vips Imageifthenelse

#### Declaration [src]

    int
    vips_ifthenelse (
      VipsImage* cond,
      VipsImage* in1,
      VipsImage* in2,
      VipsImage** out,
      ...
    )

#### Description [src]

This operation scans the condition image `cond` and uses it to select pixels from either the then image `in1` or the else image `in2`. Non-zero means `in1`, 0 means `in2`.

Any image can have either 1 band or n bands, where n is the same for all the non-1-band images. Single band images are then effectively copied to make n-band images.

Images `in1` and `in2` are cast up to the smallest common format. `cond` is cast to uchar.

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 `blend` is `TRUE`, then values in `out` are smoothly blended between `in1` and `in2` using the formula:

    out = (cond / 255) * in1 + (1 - cond / 255) * in2

Optional arguments

- `blend`: `gboolean`, blend smoothly between `in1` and `in2`

See also

`vips_equal()`.

This method is not directly available to language bindings.

#### Parameters

`in1`

  Type: `VipsImage`

  Then `VipsImage`.

  The data is owned by the caller of the method.

`in2`

  Type: `VipsImage`

  Else `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.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.