$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:Response
- The result is a single
image, not adataarray. Raster results come in theimage_formatyou choose. - Image URLs are temporary: files are kept for about 24 hours, so download them. See Limits and sizes.
creditsis 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
Upload local files
Upload local files
Draw a mask in code
Draw a mask in code
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.
Erase from an SVG
Erase from an SVG
The image can be an SVG. The mask is always a raster file: PNG, JPG, or WEBP.
Related
Remove background
Cut out the subject instead of erasing an area.
Pricing
Prices of every model and tool.