remove-image-background
Remove a solid background from an image and write a transparent PNG, using the bundled remove_background.py. Use this whenever the user wants to knock out, drop, or make transparent the background of a logo, banner, icon, or other static image asset in a repo, or to trim an asset to its content and pad it. Pairs with generate-art: generate a flat asset, then key its background here. Do NOT trigger for photo cutouts needing subject segmentation, for runtime image processing, or for editing source code rather than an image file.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-21
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- remove-image-background
- description
- Remove a solid background from an image and write a transparent PNG, using the bundled remove_background.py. Use this whenever the user wants to knock out, drop, or make transparent the background of a logo, banner, icon, or other static image asset in a repo, or to trim an asset to its content and pad it. Pairs with generate-art: generate a flat asset, then key its background here. Do NOT trigger for photo cutouts needing subject segmentation, for runtime image processing, or for editing source code rather than an image file.
02 资源文件 2
- 参考文档README.md1.6 KB
- 脚本scripts/remove_background.py6.7 KB
03 SKILL.md 正文
Remove background
Build-time asset tooling. The engine is scripts/remove_background.py; the
skill body is the recipe around it. It turns a solid background into alpha,
trims to the content, and de-fringes the edges so no halo survives on a new
backdrop.
Boundary: build-time only
This post-processes static PNGs checked into a repo. It never runs inside a
shipped application or its request path. It has one dependency (pillow)
pulled into an ephemeral uv env, so it needs no project install.
Prerequisites
uvavailable. The script is a self-contained PEP 723 script:uv runinstallspillowinto an ephemeral env.
Run
uv run scripts/remove_background.py --in <input> --out <output.png> [flags]
--in/--out: required. Writing back to the same path is fine.--mode:flood(default) orkey. See "Which mode" below.--bg: background color.auto(default, averages the four corners) or an explicitR,G,Bwhen the corners are not representative.--tolerance/-t: color distance still counted as background (default60). Raise it when a tint survives; lower it when real art gets eaten.--trim/--no-trim: crop to the content bounding box (default on).--pad: transparent padding as a fraction of content height (default0). A banner reads better with0.10to0.15.--defringe/--no-defringe: clear anti-aliased edge pixels still tinted by the old background (default on). This is what kills the halo.
Which mode
The default flood fill clears only background that touches the border, so a
gap INSIDE the artwork that happens to match the background color stays intact.
Reach for key only when the subject contains no such interior region, because
key clears every matching pixel wherever it sits and will punch holes through
an interior that shares the background color.
The input matters more than the flags
Keying is clean only when the source is clean. A flat, solid-color asset on a uniform background keys with no artifacts. A textured or painterly render leaves a mottled fill, and any spot inside the art that shares the background color becomes a hole. When a result looks grubby, fix the SOURCE (regenerate it flat via generate-art) rather than fighting the key with tolerance.
Workflow
- Check the source. Confirm the background is roughly uniform and the subject does not share that exact color internally. If it is textured, prefer regenerating a flat version first.
- Run the script, starting from defaults.
- Verify the alpha. Composite the output over both a light and a dark background (and a saturated color like magenta to expose fringing), then view the results. Do not claim success without looking, since a white-on-white view hides every artifact.
- Iterate. Adjust
--tolerance, switch--mode, or set--bgexplicitly. If holes or fringing persist, the source is the problem. - Show the user the result and the final path.
Notes
- Alpha edges are binary (no soft feather). This suits flat assets that get downscaled for display, which anti-aliases the edge naturally. It is not a photo-grade matting tool.
04 同仓库更多 Skills
fake-skill
A skill used only by shakedown's own offline tests.
shakedown-canary
Run the shakedown canary check. Use whenever someone asks to run the canary check, verify the harness, or confirm shakedown is wired up correctly.
create-cases
Author a shakedown cases file (`shakedowns/<slug>.cases.toml`) for an existing agent skill: read the skill, turn what it promises into cases, supply fixtures for the commands it must not really run, and check the result with `shakedown case validate`. Use this whenever someone wants to measure, smoke-test, or add conformance cases for a skill, asks "how do I test this skill", points at a SKILL.md and wants cases written, or is editing a `.cases.toml`. Use it even when they only name the skill ("write cases for connect-agent-to-hub") without mentioning shakedown or TOML.
analyze-results
Read a shakedown report (`shakedown-report.json`) and say which file to open: the measured skill's own `SKILL.md`, the `shakedowns/<slug>.cases.toml` holding its cases, the harness block in `shakedown.toml`, or a flag on the run itself. Use this whenever someone has run `shakedown case run` and wants to know what a number means or what to do about it, pastes a report or the PR comment rendered from one, asks why `skill_fired`, `tool_used`, `artifact_created` or `inputs_resolved` came out low, asks whether a rate is worth acting on, or says a conformance run failed and they cannot tell whose fault it is. Use it even when they only quote the percentage ("my skill scores 60% on inputs_resolved, now what") without naming shakedown or the report file.
add-harness
Add a new agent harness (opencode, Gemini CLI, Codex, Amp, a local Ollama-backed runner, or any CLI that loads skills) to a shakedown config so its skill conformance can be measured, and diagnose a harness that `shakedown doctor` reports as not qualifying. Use this whenever someone wants shakedown to run against a harness it does not yet support, asks why a harness fails doctor, asks how to point an existing harness at a different model or provider, or is editing the `[harness.*]` block of a shakedown.toml. Use it even when they only name the tool ("can this test opencode?") without mentioning config or TOML.
create-cases
Author a shakedown cases file (`shakedowns/<slug>.cases.toml`) for an existing agent skill: read the skill, turn what it promises into cases, supply fixtures for the commands it must not really run, and check the result with `shakedown case validate`. Use this whenever someone wants to measure, smoke-test, or add conformance cases for a skill, asks "how do I test this skill", points at a SKILL.md and wants cases written, or is editing a `.cases.toml`. Use it even when they only name the skill ("write cases for connect-agent-to-hub") without mentioning shakedown or TOML.