Skip to main content
Erase region removes the part of an image that a mask marks. Use it to take out objects, text, or blemishes.

$0.002

per request

Image and mask

up to 10 MB and 16 MP each

POST /v1/images/eraseRegion

endpoint

Try it

Get an API token on your profile page (it needs a positive API units balance) and set it once per terminal session:
Then run. The request erases the white area of a sample mask from a public sample illustration:

Response

  • The result is a single image, not a data array. Raster results come in the image_format you choose.
  • Image URLs are temporary: files are kept for about 24 hours, so download them. See Limits and sizes.
  • credits is the number of API units charged for the request.

Parameters

The image must be PNG, JPG, WEBP, or SVG. The mask must be PNG, JPG, or WEBP. Both must be under 10 MB, up to 16 MP, with sides between 256 and 4096 px, and the mask must have exactly the size of the image. See Input images. The mask is a grayscale image. White pixels (255) mark the area to erase, black pixels (0) stay as they are. Every pixel must be pure black or pure white.

Examples

This script makes a black mask the size of the image and paints a white rectangle where the object is. Then it sends both files.
The image can be an SVG. The mask is always a raster file: PNG, JPG, or WEBP.

Remove background

Cut out the subject instead of erasing an area.

Pricing

Prices of every model and tool.