Image background removal
Try it interactively →POST /api/image-remove-bgRemove a uniform background from an image. Picks the dominant background colour automatically, or accepts an explicit hex value, and replaces it with transparency.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| image* | file | — | Input image (PNG / JPEG / WebP). |
| color | string | "white" | Background colour to make transparent (CSS / IM colour name or #rrggbb). |
| fuzz | number (0…100) | 10 | Tolerance percentage 0–100. Higher catches more of an anti-aliased edge. |
| invert | boolean | false | When true, keep matching-colour pixels and remove everything else. |
| format | enum (png | webp) | "png" | Output format. PNG and WebP support transparency; JPEG isn't offered (it can't preserve alpha). |
Response
Modes: binary, base64-json. Cache: yes (24h TTL).
Code samples
Built from the white-bg example.
# Download or substitute the example input:
# curl -O https://xtract.bot/examples/image-png-to-webp/sample.png
IMAGE=$(base64 -w0 < sample.png)
curl -X POST https://api.xtract.bot/api/image-remove-bg \
-H "Content-Type: application/json" \
-H "Accept: application/octet-stream" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"color": "white",
"fuzz": 10,
"image": "'"$IMAGE"'"
}'