Removes the background from an image, leaving the foreground subject with transparency. Use when you need to isolate subjects, create cutouts, or prepare images for compositing.
Removes the background from an image, leaving only the foreground subject with transparency.
agent-media image remove-background --in <path> [options]
| Option | Required | Description |
|---|---|---|
--in | Yes | Input file path or URL |
--out | No | Output path, filename or directory (default: ./) |
--provider | No | Provider to use (local, fal, replicate) |
Returns a JSON object with the processed image path:
{
"ok": true,
"media_type": "image",
"action": "remove-background",
"provider": "fal",
"output_path": "nobg_123_abc.png",
"mime": "image/png",
"bytes": 34567
}
Remove background from local file:
agent-media image remove-background --in portrait.jpg
Remove background using specific provider:
agent-media image remove-background --in portrait.jpg --provider replicate
Runs locally on CPU using Transformers.js, no API key required.
Xenova/modnet modelmutex lock failed error — ignore it, the output is correct if "ok": trueagent-media image remove-background --in portrait.jpg --provider local
FAL_API_KEYbirefnet/v2 modelREPLICATE_API_TOKENbirefnet model