---
name: "im_extract"
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_extract"
---

# im\_extract(3)

extract a portion of an image

## NAME

im\_extract\_areabands, im\_extract\_bands, im\_extract\_area - extract a portion of an image

## SYNOPSIS

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

int im\_extract\_areabands( IMAGE \*in, IMAGE \*out, \
\
   int left, int top, int width, int height, int band, int nbands )

int im\_extract\_area( IMAGE \*in, IMAGE \*out,\
\
   int left, int top, int width, int height )

int im\_extract\_bands( IMAGE \*in, IMAGE \*out, \
\
   int chsel, int nbands )

## DESCRIPTION

**[im\_extract\_areabands(3)](/im_extract_areabands/3.md)** extracts the rectangular portion of the image defined by  **left,** **top,** **width,** and **height of image** **in** and writes the result to image  **out.** The area must lie entirely within in the image. Selects the set of  **nbands** bands  starting at band number **band** (numbering bands from zero).

Works for any size image, any number of bands, any type. Works for LABPACK coded images too! But disallows band extraction in this case.

**[im\_extract\_area(3)](/im_extract_area/3.md)** is a convenience function which extracts an area from an image, leaving the bands the same.

**[im\_extract\_bands(3)](/im_extract_bands/3.md)** takes  **nbands** out of an image, starting from band **band.** So, for example, nbands == 2, bands == 1 will form a two band image from an RGB image, where the two bands are the G and the B bands.

## RETURN VALUE

The function returns 0 on success and -1 on error.

## SEE ALSO

[im\_insert(3)](/im_insert/3.md), [im\_lrjoin(3)](/im_lrjoin/3.md), [im\_lrmerge(3)](/im_lrmerge/3.md), [im\_stats(3)](/im_stats/3.md), [im\_region\_region(3)](/im_region_region/3.md).

## COPYRIGHT

J. Cupitt,

## AUTHOR

J. Cupitt - 11/04/1990
