BackgroundCut API v2

The power of BackgroundCut, automated

$  curl -H 'Authorization: YOUR_API_KEY'
       -F 'image_file=@/your/image/file.jpg'
       -f https://api.backgroundcut.co/v2/cut/
       -o output.png

Sample Code Examples

Remove background from image

Image File   
Python PHP NodeJs Go

Output Formats

You can request one of two formats via the "return_type" parameter:

Format Resolution Pros & Cons
PNG (default) Up to 12 Megapixels + Simple integration
+ Supports transparency
- Extremely large file size
WEBP (recommended) Up to 12 Megapixels + Simple integration 
+ Supports transparency
+ Small file size

How to use quality parameter for WEBP format?

WebP is a modern image format that provides superior lossless and lossy compression for images. Depending on the level of compression, it can range from 1 to 100. For example, to get lossless output, you can send a "return_type" parameter as WEBP_100, and to set some compression, you can send the "return_type" parameter as WEBP_50.

API Reference

API Endpoint https://api.backgroundcut.co/v2/cut/
Method POST

Heading

Authorization (string) YOUR_API_KEY

Parameters

image_file Source image file (binary). Supports only PNG, JPG, WEBP
image_file_b64 Source image file (base64-encoded string)
max_resolution Maximum output resolution (specified in pixels). Upto 12000000, i.e 12MP. For eg, 4000000 outputs image of maximum resolution of 4MP.
quality 'High', 'Medium'(default), 'Low'. 'High' quality takes the most time while 'Low' takes the least time to process.
return_type 'PNG'(default), 'WEBP' (recommended).
channels Request either the finalized image ("rgba", default) or an alpha mask ("alpha"). Note: Since BackgroundCut also applies RGB color corrections on edges, using only the alpha mask often leads to a lower final image quality. Therefore "rgba" is recommended when quality parameter is set to 'High'.

Response

Code : 200 Successfully removed image background
Code : 400 Error: Invalid parameters or unable to process input image file (No credit deducted)
Code: 401 Error: API-KEY missing or invalid API-KEY
Code: 402 Error: Payment required. No credits left.
Code: 405 Error: Invalid request METHOD (Ensure the request is of type POST)
Code: 405 Error: Invalid request METHOD (Ensure the request is of type POST)
Code: 413 Error: Request Entity Too Large. File size should not exceed 12MB when uploading.
Code: 429 Error: API rate limit crossed (No credit deducted)
Code: 450 Error: Invalid POST URL (Ensure the URL is https://api.backgroundcut.co/v2/cut/)

API Rate Limit

BackgroundCut implements rate limits dynamically. There is a default limit of 40 requests per minute for APIs. Depending on usage in the current minute, rate limits double the following minute up to a maximum of 500 requests per minute. The basic rate limit of 40 can be increased upon request.