AgentSkillsCN

image-remove-background

去除图像背景,使前景主体保留透明效果。当您需要将主体单独分离、制作剪切蒙版,或为后期合成准备图像时,可使用此功能。

SKILL.md
--- frontmatter
name: image-remove-background
description: 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.

Image Remove Background

Removes the background from an image, leaving only the foreground subject with transparency.

Command

bash
agent-media image remove-background --in <path> [options]

Inputs

OptionRequiredDescription
--inYesInput file path or URL
--outNoOutput path, filename or directory (default: ./)
--providerNoProvider to use (local, fal, replicate)

Output

Returns a JSON object with the processed image path:

json
{
  "ok": true,
  "media_type": "image",
  "action": "remove-background",
  "provider": "fal",
  "output_path": "nobg_123_abc.png",
  "mime": "image/png",
  "bytes": 34567
}

Examples

Remove background from local file:

bash
agent-media image remove-background --in portrait.jpg

Remove background using specific provider:

bash
agent-media image remove-background --in portrait.jpg --provider replicate

Providers

local

Runs locally on CPU using Transformers.js, no API key required.

  • Uses Xenova/modnet model
  • Models downloaded on first use (~25MB)
  • You may see a mutex lock failed error — ignore it, the output is correct if "ok": true
bash
agent-media image remove-background --in portrait.jpg --provider local

fal

  • Requires FAL_API_KEY
  • Uses birefnet/v2 model

replicate

  • Requires REPLICATE_API_TOKEN
  • Uses birefnet model