Real Transparent Background
Quick Start
Use scripts/checkerboard_to_alpha.py for deterministic background extraction when an image already contains a visible gray/white checkerboard or similar fake transparent background. Prefer this script over AI image regeneration when the foreground must remain unchanged.
Run it with a Python that has Pillow and NumPy available:
python "/path/to/real-transparent-background-skill/scripts/checkerboard_to_alpha.py" "/path/to/image.png" --suffix=-transparent
For multiple files:
python "/path/to/real-transparent-background-skill/scripts/checkerboard_to_alpha.py" "/path/to/a.png" "/path/to/b.png" --output-dir "/path/to/transparent" --suffix=-transparent
Workflow
- Treat the provided image path(s) as edit targets, not style references.
- Save non-destructively by default. Use a sibling filename such as
name-transparent.pngunless the user explicitly asks to overwrite. - Use the bundled script for fake checkerboard or flat neutral backgrounds. It estimates the background colors from border pixels, flood-fills only background connected to the canvas edges, and writes an RGBA PNG.
- For images with colored glows, halos, lightbulbs, or aura effects that should remain semi-transparent, add
--soft-colored-edges. For thin pale foreground details such as whiskers or white line art, omit that flag to preserve colored details. - If writing outputs outside the current workspace, request filesystem approval before copying or saving there.
- Validate the result before finishing: output mode should be
RGBA; corner alpha should be0; foreground sample points should remain255.
Script Notes
scripts/checkerboard_to_alpha.py supports:
- one or more input files
--output-dirfor batch output--outputfor a single explicit output path--suffixfor sibling filenames--overwriteonly when replacement is intentional- threshold tuning for unusual backgrounds
The script prints one JSON line per processed file with output path, image size, palette estimate, alpha counts, and corner-alpha samples. Use those values in the final response when reporting validation.
When To Avoid The Script
Use a true segmentation or model-native transparency workflow instead when the background is not connected to image borders, is a complex scene, overlaps foreground colors heavily, or the task requires inventing missing foreground pixels. Ask before switching to a generative or API fallback if it could alter the subject.