# Image Remove Background

> >-

- **Type:** Skill
- **Install:** `agentstack add skill-godot-fun-godot-framework-image-remove-background`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [godot-fun](https://agentstack.voostack.com/s/godot-fun)
- **Installs:** 0
- **Category:** [Content & Media](https://agentstack.voostack.com/c/content-and-media)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [godot-fun](https://github.com/godot-fun)
- **Source:** https://github.com/godot-fun/godot-framework/tree/main/.cursor/skills/image-remove-background

## Install

```sh
agentstack add skill-godot-fun-godot-framework-image-remove-background
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Image Remove Background (rembg)

Remove image backgrounds with AI matting via **rembg**. Output is **RGBA PNG** with transparent background — ready for Godot sprites and UI.

## Rules

When this skill applies, read and follow [skill-dependency-manager](../../rules/skill-dependency-manager.md) — run scripts as documented, install missing tools into `.dependency/`.

- Run `remove_background.py` through the **`rembg` manifest entry** (`.dependency/rembg/.venv/`). Never use host `python`, `py`, `python3`, or any interpreter outside `.dependency/`.
- Do not hand-write `rembg i` / `rembg p` — use the bundled script.
- `populated: false` for `rembg` is not a reason to skip. Install first, set `populated: true`, retry the same command.
- Pass the input path as-is (chat attachment path, `Downloads/foo.png`, project folder, etc.). Output goes to `/transparent/` by default — no path rewriting.

## Setup (first run)

From project root:

```bash
.dependency/python/python -m venv .dependency/rembg/.venv
.dependency/rembg/.venv/Scripts/python -m pip install "rembg[cpu]"
```

GPU (CUDA) — faster batch processing:

```bash
.dependency/rembg/.venv/Scripts/python -m pip install "rembg[gpu]"
```

Register in `.dependency/manifest.json`:

```json
"rembg": {
  "populated": true,
  "bin": ".dependency/rembg/.venv/Scripts/python.exe"
}
```

Use `bin/python` on Unix. Model weights download on first run (~hundreds of MB).

## Quick Start

**Default: create a `transparent/` folder under the input path** and write outputs there (never overwrites sources):

```bash
# Single file → image/sprites/transparent/hero.png
.dependency/rembg/.venv/Scripts/python .cursor/skills/image-remove-background/scripts/remove_background.py image/sprites/hero.png

# Directory batch → image/sprites/hero/transparent/.png
.dependency/rembg/.venv/Scripts/python .cursor/skills/image-remove-background/scripts/remove_background.py image/sprites/hero -r
# e.g. image/sprites/hero/sub/foo.png → image/sprites/hero/transparent/sub/foo.png
```

Custom output directory:

```bash
.dependency/rembg/.venv/Scripts/python .cursor/skills/image-remove-background/scripts/remove_background.py image/sprites/hero \
  --output-dir image/sprites/hero_cutout
```

## Model selection

| Model | Use case |
|-------|----------|
| `u2net` *(default)* | General objects, icons, props |
| `u2netp` | Faster / lighter; smaller assets |
| `isnet-general-use` | Higher quality general matting |
| `birefnet-general` | Best general quality (slower) |
| `birefnet-portrait` | Characters / portraits |
| `u2net_human_seg` | Human figures only |

```bash
.dependency/rembg/.venv/Scripts/python .cursor/skills/image-remove-background/scripts/remove_background.py image/characters \
  --model birefnet-portrait --output-dir image/characters_cutout
```

## Edge quality (alpha matting)

For hair, fur, or soft edges, enable alpha matting:

```bash
.dependency/rembg/.venv/Scripts/python .cursor/skills/image-remove-background/scripts/remove_background.py image/portrait.png \
  --alpha-matting --output-dir image/portrait_cutout
```

## Defaults

| Option | Default | Notes |
|--------|---------|-------|
| Output | `/transparent/` | Folder is auto-created under the file or directory you pass; use `--output-dir` for a custom path |
| `--model` | `u2net` | See table above |
| `--pattern` | `*.png` | Also matches `.jpg`, `.jpeg`, `.webp` |
| `--alpha-matting` | off | Enable for fine edge detail |
| `--crop` | off | Trim transparent borders after matting |
| Overwrite | off | Pass `--overwrite` to replace existing outputs |

## Agent workflow

1. **Paths** — Pass whatever path the user gives or the chat `` path directly. Output lands in `transparent/` next to that input.
2. **Trial first** — run on 1 image, inspect the `transparent/` or `--output-dir` result before batch.
3. **Pick model** — `u2net` for generic assets; `birefnet-portrait` for characters; `birefnet-general` when quality matters.
4. **Soft edges** — try `--alpha-matting` if halos or jagged hair/fur appear.
5. **Sprite sheets** — skip `*_sheet.png` by default; process individual frames unless the user asks otherwise.
6. **Already transparent** — script still runs; rembg re-mats from visible RGB. Warn user if source already has alpha.
7. **Revert** — delete output folder or `git restore` if needed; sources are never modified.

## Troubleshooting

| Issue | Fix |
|-------|-----|
| `rembg` missing | Follow **Setup**; update manifest |
| Very slow | Install `rembg[gpu]`; try `--model u2netp` |
| Jagged edges | `--alpha-matting` |
| Wrong subject removed | Switch model; try `birefnet-general` |
| Leftover background color | Re-run with `--alpha-matting`; check source contrast |
| OOM on large images | Script auto-downscales inputs above 4096 px longest side |

## Related

- Flat white/green/magenta AI backgrounds: [image-remove-white-background](../image-remove-white-background/SKILL.md) (prefer over rembg)
- rembg docs: https://github.com/danielgatis/rembg

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [godot-fun](https://github.com/godot-fun)
- **Source:** [godot-fun/godot-framework](https://github.com/godot-fun/godot-framework)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-godot-fun-godot-framework-image-remove-background
- Seller: https://agentstack.voostack.com/s/godot-fun
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
