xtract.bot

Replace background

Try it interactively →
POST /api/image-replace-background

Replace an image's background colour. Detects or accepts the existing background colour and fills it with the colour you specify (no transparency).

Like `image-remove-bg` but, instead of producing transparency, fills the removed background with a specified colour. Handy for swapping a "white-background" product shot to a different solid colour without doing the compositing yourself.

Inputs

NameTypeDefaultDescription
image*fileInput image bytes.
keyColorstring"green"Colour to replace (`green`, `blue`, or CSS hex).
bgColorstring"#ffffff"Replacement colour (CSS hex or named).
tolerancenumber (1…90)25Hue tolerance (degrees).
softnessnumber (0…30)10Soft-edge band width.
formatenum (jpeg | png)"jpeg"Output encoding.
qualitynumber (1…100)90JPEG quality.

Response

Modes: binary, json. Cache: yes (24h TTL).