agentleFS
godot-fungodot-fun/gai/.agents/skills/image-remove-white-background/SKILL.md

image-remove-white-background

Skill210 starsChanged todayMITView on GitHub

Removes solid-color backgrounds (white, green #00FF00, magenta #FF00FF) from a single AI-generated image using color key and border flood fill — not AI matting. Use when rembg over-removes foreground, for flat white/green/magenta backgrounds, color key cutout, white-background cutout, green screen, or chroma key before Godot sprite import.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Remove flat solid-color backgrounds with color key + flood fill.

    line 12
  2. Very specific:

    When this skill applies, read and follow dependency-manager — run scripts as documented, install missing tools into .dependency/.

    line 20
  3. Very specific:

    Run remove_white_bg.py through the image-remove-white-background manifest entry (.dependency/image-remove-white-background/.venv/).

    line 22
  4. Very specific:

    Do not hand-write FFmpeg colorkey / ImageMagick commands — use the bundled script.

    line 23
  5. Very specific:

    Use bin/python on Unix.

    line 46
  6. Very specific:

    Both --image is required: Default output: <image-dir>/image-remove-white-background/<image-name>.png

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Image Remove White / Chroma Background

Remove flat solid-color backgrounds with color key + flood fill. Output is RGBA PNG with transparency — ready for Godot sprites and UI.

Unlike image-remove-background (rembg AI matting), this skill only removes pixels that match the key color. It does not guess what is "subject" vs "background", so white clothing, props, and effects are preserved unless they touch the outer background through matching pixels.

Single file only. Pass one image with --image; directories are not supported.

Rules

When this skill applies, read and follow dependency-manager — run scripts as documented, install missing tools into .dependency/.

  • Run remove_white_bg.py through the image-remove-white-background manifest entry (.dependency/image-remove-white-background/.venv/). Never use host python, py, python3, or any interpreter outside .dependency/.
  • Do not hand-write FFmpeg colorkey / ImageMagick commands — use the bundled script.
  • Single file only. Pass one image with --image; directories are not supported.
  • populated: false for image-remove-white-background 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 <image-dir>/image-remove-white-background/ by default — no path rewriting; never overwrite sources.

Setup (first run)

From project root:

.dependency/python/python -m venv .dependency/image-remove-white-background/.venv
.dependency/image-remove-white-background/.venv/Scripts/python.exe -m pip install Pillow

Register in .dependency/manifest.json:

"image-remove-white-background": {
  "populated": true,
  "bin": ".dependency/image-remove-white-background/.venv/Scripts/python.exe"
}

Use bin/python on Unix.

Quick Start

Both --image is required. Default output: <image-dir>/image-remove-white-background/<image-name>.png

# White AI background (default preset)
.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/sprites/hero.png

# Green screen (#00FF00) — recommended for future AI generation
.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/sprites/hero.png --preset green

# Magenta screen (#FF00FF)
.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/sprites/hero.png --preset magenta

Custom output path:

.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/sprites/hero.png -o image/sprites_cutout/

Presets

PresetKey colorDefault toleranceBest for
white (default)#FFFFFF25AI images with pure/near-white backgrounds
green#00FF0040Green-screen AI prompts (recommended)
magenta#FF00FF40Magenta-screen AI prompts

Custom key color:

.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/foo.png --color F0F0F0 --tolerance 20

Modes

ModeBehavior
global (default)Removes all pixels matching the key color. Best when the subject has no same-color interior details to preserve.
bothUnion of border and center — removes background connected to edges or to the center.
borderFlood fill from image edges only — keeps isolated white areas not reachable from edges or center (e.g. white shirt interior).
centerFlood fill from the image center outward — removes key-color regions reachable from the middle.
# Center-out flood (interior white holes)
.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/foo.png --mode center

# Edge + center without removing every white pixel
.dependency/image-remove-white-background/.venv/Scripts/python.exe .ai/image-remove-white-background/remove_white_bg.py --image image/foo.png --mode both

Defaults

OptionDefaultNotes
--imageRequiredSingle supported image file
Output<image-dir>/image-remove-white-background/<name>.pngUse -o / --output for custom file or directory
--presetwhitegreen / magenta for chroma-screen AI art
--modeglobalUse border or both when same-color interior details must be preserved
--tolerancepreset-specificRaise if background remnants remain; lower if foreground edges erode
--feather2Gaussian soft edge on alpha; 0 for hard edges
--cropoffTrim transparent borders after keying

Supported inputs: .png, .jpg, .jpeg, .webp, .bmp, .gif, .tif, .tiff, .avif, .ico.

Agent Workflow

  1. Pick skill — flat solid background → this skill; complex/photo backgrounds → image-remove-background.
  2. Paths — Pass whatever path the user gives or the chat <image_files> path directly with --image. Output lands in image-remove-white-background/ next to that input.
  3. One file per run — process one image, verify the result, then repeat for additional files if needed.
  4. Preset — white for existing white-bg AI art; tell user to switch AI prompts to --preset green or --preset magenta going forward.
  5. Tolerance — if halos remain, increase --tolerance by 5–10; if subject edges eat away, decrease it.
  6. Revert — delete output file or git restore; sources are never modified.

Troubleshooting

IssueFix
image-remove-white-background missingFollow Setup; update manifest
Missing --imageBoth --image and a file path are required
Directory passed to --imageRun once per file; this skill accepts image files only
Output already existsDelete the existing output or choose a different -o path
Background remnants (gray fringe)Increase --tolerance; try --feather 3
Subject edges erodedDecrease --tolerance; ensure --mode border
White clothing removedSwitch to --mode border or --mode both; avoid global for characters with white details
Green spill on subject edgesLower --tolerance; increase --feather slightly
Interior holes stay opaqueTry --mode center if the hole matches the key color at the image center; try --mode both for edge + center; otherwise --mode global only if safe, or fix in an editor
Center mode does nothingCenter pixel is not key color (subject sits in the middle) — use border, both, or split sprite sheets per frame
Wrong colors in JPEGPrefer PNG from AI export; raise tolerance slightly for compression artifacts
Wrong interpreterMust use .dependency/image-remove-white-background/.venv/Scripts/python.exe

CLI

Copy-paste commands: cli/image-remove-white-background.md

Related

  • AI matting (complex backgrounds): image-remove-background
  • Enclosed white islands after edge keying: image-region-remove-key-color-app

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.