image-bg-remove
starchild-ai-agent/official-skills
Remove backgrounds from images instantly—transparent PNGs, cutouts, and product photos in ~3 seconds.
What is image-bg-remove?
Dedicated background removal skill using Bria RMBG 2.0 model. Removes backgrounds from portraits, products, pets, and group photos to create transparent PNGs. Use when you need clean cutouts or transparent images for compositing.
- Removes backgrounds and outputs transparent PNG (RGBA)
- Handles portraits, product photos, pets, group photos, and object isolation
- Fast processing (~3 seconds per image) with low cost (~$0.01)
- Supports local files, public URLs, and custom output paths
- Batch processing via loops for multiple images
- Works with JPEG, PNG, WEBP, and BMP input formats
How to install image-bg-remove
npx skills add https://github.com/starchild-ai-agent/official-skills --skill image-bg-removeHow to use image-bg-remove
- 1.Call the remove_bg() function with either image_path (local file) or image_url (public HTTPS URL)
- 2.Optionally specify a custom output_path; otherwise the script auto-saves to output/images/ with timestamp
- 3.The script base64-encodes the image and sends it to fal.ai's Bria RMBG 2.0 model
- 4.Download the resulting transparent PNG from the local_path in the response
- 5.Deliver the local file to users via the workspace file panel or embed inline in chat
Use cases
- Remove background from ID photos or professional headshots for transparent cutouts
- Extract product images with transparent backgrounds for e-commerce listings
- Create transparent PNG cutouts of pets or animals for compositing
- Isolate foreground subjects from group photos or complex backgrounds
- Batch process multiple product images for catalog preparation
- E-commerce product photographers
- Portrait and headshot editors
- Graphic designers preparing assets for compositing
- Content creators needing transparent image cutouts
- Batch image processing workflows
image-bg-remove FAQ
image-bg-remove outputs a transparent PNG by removing the background. image-edit with action='replace_bg' replaces the background with a new scene. For best results, use image-bg-remove first to get a clean cutout, then image-edit to composite onto a new background.
Use python3 - <<'EOF' with a heredoc to avoid shell parsing errors: python3 - <<'EOF' import sys sys.path.insert(0, "skills/image-bg-remove") from exports import remove_bg result = remove_bg(image_path="uploads/photo.jpg") print(result) EOF
Yes. Call remove_bg() in a loop over a list of image paths using glob.glob() or similar. The skill processes each image independently.
Input: JPEG, PNG, WEBP, BMP (max 10 MB). Output: always transparent PNG (RGBA).
Never use the raw fal.media URL—use the local_path from the response. Save to output/images/, tell the user it's in the workspace file panel, and embed inline in chat with  on Web.
Full instructions (SKILL.md)
Source of truth, from starchild-ai-agent/official-skills.
name: image-bg-remove version: 1.0.3 description: | Background removal: transparent PNGs, cutouts, product photos, portraits, pets, group photos. Uses dedicated Bria RMBG 2.0 model — no prompt needed, fast (~3s), cheap ($0.01).
Use when removing backgrounds, creating transparent PNGs, making cutouts, extracting foreground subjects, or preparing images for compositing. metadata: starchild: emoji: "✂️" skillKey: image-bg-remove user-invocable: true disable-model-invocation: false
image-bg-remove
Use this skill for all background removal requests on Starchild.
Covers: portrait background removal (ID photos, headshots), product cutouts (e-commerce white-background), group photo background removal, pet/animal cutouts, object isolation, and preparing transparent PNGs for compositing.
Core principle: call the provided script. Do not re-implement proxy/billing plumbing.
Key difference from other image skills: this skill uses a dedicated background removal model (fal-ai/bria/background/remove — Bria RMBG 2.0), not the general-purpose nanopro/gpt models. No prompt is needed — just provide an image.
1. Quick start — local file (most common)
⚠️ Execution context — read this first. The code blocks below are Python, not shell commands. Starchild's
bashtool runs/bin/bash -c, which cannot parseexec(open(...))— pasting them directly into a bash command will fail withsyntax error near unexpected token 'open'. Also,exec(open(...))insidepython3 -cfails withNameError: __file__because the script uses__file__for path resolution.Use
python3 - <<'EOF'withfrom exports importwhen calling via the bash tool:python3 - <<'EOF' import sys sys.path.insert(0, "skills/image-bg-remove") from exports import remove_bg result = remove_bg(image_path="uploads/photo.jpg") print(result) EOFThe heredoc (
<<'EOF') preserves all quotes and newlines — no escaping needed.
exec(open('skills/image-bg-remove/remove_bg.py').read())
result = remove_bg(image_path="uploads/photo.jpg")
# result -> {"success": True, "image": {"local_path": "output/images/..."}, "cost": 0.01, "duration_s": 3.2}
The script reads the local file, base64-encodes it, and sends it to fal.ai as a data URI — no manual URL publishing needed.
2. Quick start — public URL
exec(open('skills/image-bg-remove/remove_bg.py').read())
result = remove_bg(image_url="https://example.com/photo.jpg")
3. Quick start — custom output path
exec(open('skills/image-bg-remove/remove_bg.py').read())
result = remove_bg(
image_path="uploads/product.jpg",
output_path="output/images/product_transparent.png",
)
Delivering the result to the user — IMPORTANT
Never hand the user the raw fal.media URL. fal serves files with restrictive CSP headers. The only reliable delivery path is the already-downloaded local file:
- Use the image's
local_path(e.g.output/images/xxx.png) — the script always downloads on success. - Tell the user the file is saved to
output/images/and viewable in the workspace file panel. - On Web channel, embed inline so the user can preview in chat:
 - On Telegram / WeChat: send via
send_to_telegram(file_path="output/images/...", message_type="image")orsend_to_wechat(file_path="output/images/...", message_type="image").
4. Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
image_path | yes* | — | Local workspace file path to the source image |
image_url | yes* | — | Public HTTPS URL of the source image |
output_path | no | auto | Custom output file path. If not set, saves to output/images/ with timestamp. |
*At least one of image_path or image_url must be provided. If both are given, image_path takes priority.
No prompt parameter — this is a pure tool skill. The dedicated model handles background removal automatically without any text instruction.
5. When to use this skill
Use image-bg-remove when the user wants to:
| User says | Use this skill |
|---|---|
| "remove the background" / "去背景" / "抠图" | ✅ Yes |
| "make it transparent" / "透明背景" | ✅ Yes |
| "create a cutout" / "cut out the person" | ✅ Yes |
| "product photo with white background" / "白底图" | ✅ Yes |
| "extract the foreground" / "isolate the subject" | ✅ Yes |
| "remove background from headshot" / "证件照去背景" | ✅ Yes |
| "transparent PNG" / "PNG cutout" | ✅ Yes |
| "remove background from pet photo" | ✅ Yes |
| "batch remove backgrounds" (multiple images) | ✅ Yes — call remove_bg() in a loop |
6. When NOT to use this skill — use image-edit instead
| User says | Use instead |
|---|---|
| "replace background with a beach" / "换背景" | image-edit (action="replace_bg") |
| "blur the background" / "背景虚化" | image-edit (action="edit") |
| "change background color to blue" | image-edit (action="replace_bg") |
| "edit the image" / "enhance the photo" | image-edit |
| "generate an image from text" | image-create |
Key distinction:
- image-bg-remove → removes the background → outputs transparent PNG
- image-edit (
replace_bg) → replaces the background with a new scene using a general-purpose model
For background replacement workflows, the recommended approach is:
- First use image-bg-remove to get a clean transparent cutout
- Then use image-edit (
action="blend") to composite onto a new background
This two-step approach produces better results than a single replace_bg call because the dedicated RMBG model produces cleaner edges.
7. Model details
| Property | Value |
|---|---|
| Model | fal-ai/bria/background/remove (Bria RMBG 2.0) |
| Speed | ~3 seconds |
| Cost | ~$0.01 per image |
| Output | Transparent PNG (RGBA) |
| Input formats | JPEG, PNG, WEBP, BMP |
| Max input size | 10 MB |
This is the only image skill that uses a dedicated single-purpose model. All other image skills use nanopro or gpt general-purpose models.
8. Response format
{
"success": true,
"image": {
"url": "https://fal.media/files/...",
"local_path": "output/images/20250531_153000_bg_removed.png",
"size_bytes": 245760,
"request_id": "abc123"
},
"cost": 0.01,
"duration_s": 3.2
}
On error:
{
"success": false,
"error": "File not found: uploads/missing.jpg"
}
9. Use case examples
Portrait background removal (ID photo / headshot)
exec(open('skills/image-bg-remove/remove_bg.py').read())
result = remove_bg(image_path="uploads/headshot.jpg")
if result["success"]:
print(f"Transparent headshot saved: {result['image']['local_path']}")
Product cutout for e-commerce
exec(open('skills/image-bg-remove/remove_bg.py').read())
result = remove_bg(image_path="uploads/product.jpg")
# Output: transparent PNG ready for white-background product listing
Batch processing multiple images
exec(open('skills/image-bg-remove/remove_bg.py').read())
import glob
images = glob.glob("uploads/products/*.jpg")
for img in images:
result = remove_bg(image_path=img)
if result["success"]:
print(f"✓ {img} → {result['image']['local_path']}")
else:
print(f"✗ {img}: {result['error']}")
Background removal + replacement (two-step workflow)
# Step 1: Remove background with dedicated model (better edges)
exec(open('skills/image-bg-remove/remove_bg.py').read())
result = remove_bg(image_path="uploads/portrait.jpg")
transparent_path = result["image"]["local_path"]
# Step 2: Composite onto new background with image-edit
exec(open('skills/image-edit/edit_image.py').read())
final = edit_image(
image_path=transparent_path,
prompt="place this person on a tropical beach at sunset",
action="blend",
)
10. Supported input formats
| Format | Extension | Notes |
|---|---|---|
| JPEG | .jpg, .jpeg | Most common input |
| PNG | .png | Supports existing alpha channel |
| WebP | .webp | Modern web format |
| BMP | .bmp | Legacy format |
Maximum file size: 10 MB.
11. Troubleshooting
| Issue | Solution |
|---|---|
| "File not found" | Check the file path is relative to workspace root |
| "Unsupported image format" | Convert to JPEG/PNG/WebP first |
| "Image too large" | Resize to under 10 MB before processing |
| "Submit failed: 401" | Check FAL_KEY env var (local) or sc-proxy config (production) |
| Timeout | Rare — the model usually completes in ~3s. Retry once. |
Related skills
More from starchild-ai-agent/official-skills and the wider catalog.

image-create
Pure text-to-image generation for logos, posters, illustrations, memes, game assets, and creative designs.

image-ecommerce
Generate professional e-commerce product photos: hero shots, lifestyle scenes, flat lay, detail close-ups, and platform-optimized images.

image-edit
Edit, enhance, and transform images with background replacement, upscaling, restoration, retouching, and artistic effects.

image-portrait
Generate identity-consistent styled portraits from a reference photo or text prompt.

image-tryon
Virtual try-on for clothing, accessories, hairstyles, makeup, glasses, hats, shoes, and watches.

okx
On-chain trading, analytics, security, and DeFi across 20+ blockchains via OKX OnChainOS.