trace-to-svglisted
Install: claude install-skill ginn5j/claude-skills
# Trace a drawing into an SVG path
Turns a bitmap drawing into one `<path>` you can drop into a component and tint
with `currentColor`. Stdlib Python plus macOS `sips` — nothing to install, no
`potrace`, no PIL.
**Use this instead of hand-authoring path data.** Writing bezier coordinates
from imagination, rendering, and squinting at the result has a low ceiling for
anything representational: the output reads as generic no matter how many
rounds you spend. If a reference image exists, trace it.
## How it works
1. Threshold the image to its ink.
2. Dilate to close gaps in the linework, so the outline is watertight.
3. Flood-fill the background inward from the border; everything unreached is
the figure. (This is why a *line drawing* with a white interior still yields
a filled silhouette.)
4. Walk the figure's boundary, then simplify with Douglas–Peucker.
5. Enclosed light regions — eyes, mouths, gaps between shapes — come out as
extra rings, so fill with **`fill-rule="evenodd"`**.
## Usage
```sh
python3 ~/.claude/skills/trace-to-svg/trace.py IMAGE [options]
```
Prints the path data to stdout; diagnostics go to stderr.
| Option | Default | What it does |
| --- | --- | --- |
| `--size` | 720 | Trace resolution, longest side. **The highest-leverage knob.** |
| `--threshold` | 215 | Ink cutoff 0–255; raise it to catch lighter strokes |
| `--close` | 2 | Dilate radius that closes gaps in the outline |
| `--simplify` | 2.4 | Douglas–Peucker tolerance, in source pixels