xtract.bot

Image background removal

Try it interactively →
POST /api/image-remove-bg

Remove a uniform background from an image. Picks the dominant background colour automatically, or accepts an explicit hex value, and replaces it with transparency.

Removes a uniform background colour from an image and replaces it with transparency. The background colour is detected automatically (most common edge colour) or you can pass an explicit hex value. Works well for clean product shots and graphics with flat-colour backgrounds. For photographs with complex backgrounds (foliage, varied lighting) consider an AI-based service instead — this is a simple colour-key tool, not a learned segmentation model.

Inputs

NameTypeDefaultDescription
image*fileInput image (PNG / JPEG / WebP).
colorstring"white"Background colour to make transparent (CSS / IM colour name or #rrggbb).
fuzznumber (0…100)10Tolerance percentage 0–100. Higher catches more of an anti-aliased edge.
invertbooleanfalseWhen true, keep matching-colour pixels and remove everything else.
formatenum (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"'"
}'