Skip to main content

Function: cropRegion()

cropRegion(source, mask, opts?): Promise<Buffer>

Defined in: packages/agentos/src/io/segmentation/consumers/cropRegion.ts:13

Apply a mask as the alpha channel of the source image and crop to the mask's bbox, producing a transparent cutout (sprite primitive / CLIP-embed input).

Parameters

source

string | Buffer | Uint8Array

mask

SegmentMask

opts?

background?

"transparent" | "opaque"

'transparent' (default) keeps alpha; 'opaque' flattens to black

pad?

number

pixels to expand the crop on each side (default 0)

Returns

Promise<Buffer>