Remove the background

POST/v1/background/remove
RapidAPI ● LiveApyHub ● Live

Send one photo by URL, base64 or file upload. format: json (default) returns a PNG data URI plus the size, the subject's bounding box and how much of the image it covers; png, webp and jpeg return the image bytes.

background is transparent or a colour such as #FFFFFF (JPEG needs a colour). crop: true trims to the subject, with padding pixels around it; max_size sets the longest side of the output. Choose quality: best for detail or fast for previews.

More examples and contract notes

More examples

Transparent PNG file

{
  "image": {
    "url": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"
  },
  "format": "png"
}

Product photo on white, cropped (JPEG)

{
  "image": {
    "url": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"
  },
  "format": "jpeg",
  "background": "#FFFFFF",
  "crop": true,
  "padding": 40
}

Fast WebP thumbnail

{
  "image": {
    "url": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"
  },
  "format": "webp",
  "quality": "fast",
  "max_size": 512
}

Body parameters

application/json
cropboolean

Crop the result to the subject's bounding box.

default false
paddinginteger

Pixels kept around the subject when `crop` is true.

default 0min 0max 1000
max_sizeinteger

Longest side of the output in pixels (default: original, at most 4096).

default nullmin 64max 4096
qualitybest · fast

best (default) prioritizes detail; fast is suitable for previews. Compare both on your own images.

default "best"
formatjson · png · webp · jpeg

`json` returns metadata plus a PNG data URI; `png`/`webp` return the image bytes; `jpeg` needs an opaque `background`.

default "json"
backgroundstring

`transparent`, or a colour `#RRGGBB` to place the subject on.

default "transparent"
imageobjectREQUIRED
2 child fields
urlstring

Public http(s) URL of the image (≤ 20 MB). Private and internal addresses are refused.

default nullmax length 2048
base64string

The image as base64 (a `data:` URI is fine), ≤ 20 MB decoded.

default nullmax length 27962090
multipart/form-data
filebinaryREQUIRED

The image (PNG, JPEG, WebP, GIF, BMP or TIFF; ≤ 20 MB)

cropboolean

Crop the result to the subject's bounding box.

default false
paddinginteger

Pixels kept around the subject when `crop` is true.

default 0min 0max 1000
max_sizeinteger

Longest side of the output in pixels (default: original, at most 4096).

min 64max 4096
qualitybest · fast

best (default) prioritizes detail; fast is suitable for previews. Compare both on your own images.

default "best"
formatjson · png · webp · jpeg

`json` returns metadata plus a PNG data URI; `png`/`webp` return the image bytes; `jpeg` needs an opaque `background`.

default "json"
backgroundstring

`transparent`, or a colour `#RRGGBB` to place the subject on.

default "transparent"

Responses

The result: JSON (metadata + PNG data URI) or the image bytes, per `format`

application/json
formatstringREQUIRED

Encoding of `data_uri`

media_typestringREQUIRED
widthintegerREQUIRED

Output width in pixels

heightintegerREQUIRED

Output height in pixels

bytesintegerREQUIRED
data_uristringREQUIRED

`data:<media_type>;base64,…`

bboxobjectREQUIRED
4 child fields
xintegerREQUIRED
yintegerREQUIRED
widthintegerREQUIRED
heightintegerREQUIRED
foreground_rationumberREQUIRED

Share of the original image covered by the subject (0–1)

qualitybest · fastREQUIRED

best (default) prioritizes detail; fast is suitable for previews. Compare both on your own images.

image/png

Binary response body.

image/webp

Binary response body.

image/jpeg

Binary response body.