---
name: "im_blend"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/im_ifthenelse"
---

# im\_blend(3)

use an unsigned char image to join two images together

Part of [im\_ifthenelse(3)](/im_ifthenelse/3.md).

## NAME

im\_ifthenelse - use an unsigned char image to join two images together

## SYNOPSIS

**#include \<vips/vips.h\>**

**int im\_ifthenelse(c, a, b, out)**\
 **IMAGE \*c, \*a, \*b, \*out;**

**int im\_blend(c, a, b, out)**\
 **IMAGE \*c, \*a, \*b, \*out;**

## DESCRIPTION

**im\_ifthenelse** builds an output image which uses some pels from a and some from b: if the conditional image c is non-zero at that point, the pel comes from a; if it is zero, the pel comes from b.

The conditional image c can have either 1 band, in which case entire pels come either from a or b, or n bands, where n is the number of bands in both a and b, in which case individual band elements are chosen from a and b.

Images a and b must match in size, type and number of bands.

**[im\_blend(3)](/im_blend/3.md)** works just as [im\_ifthenelse(3)](/im_ifthenelse/3.md), except that instead of selecting between a and b, values in the condition image are used to softly blend between the two. 255 means a only, 0 means b only, 128 means 50:50.

## RETURN VALUE

0 on success and -1 on error.

## SEE ALSO

[im\_equal(3)](/im_equal/3.md), im\_and(3).

## COPYRIGHT

National Gallery

## AUTHOR

J. Cupitt
