trace-to-svg
Skill0 starsChanged 31 days agoMITView on GitHub
Trace a bitmap drawing (png, jpeg, heic, screenshot) into a single simplified SVG path that can be tinted with currentColor. Use when the user wants artwork turned into an icon, glyph, game tile, logo, or silhouette; when they ask to "trace", "vectorize", or "convert to SVG"; or when hand-authoring SVG path data for an illustration is going badly and a reference image exists.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- FuturePresentLabs/agent-skillstheir own version, first seen Feb 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- FuturePresentLabs/agent-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 52
Always run with --preview, then screenshot it in headless Chrome and look:
- Very specific: line 81
--cropbefore anything else: if the image has a background, a second subject, or a part you don't want.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
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
- Threshold the image to its ink.
- Dilate to close gaps in the linework, so the outline is watertight.
- 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.)
- Walk the figure's boundary, then simplify with Douglas–Peucker.
- Enclosed light regions — eyes, mouths, gaps between shapes — come out as
extra rings, so fill with
fill-rule="evenodd".
Usage
python3 "${CLAUDE_SKILL_DIR}/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 |
--min-hole | 520 | Drop enclosed regions smaller than this many pixels |
--crop | 0,0,1,1 | x0,y0,x1,y1 as fractions, to isolate the subject |
--box | 32 | viewBox size the result is fitted into |
--out | — | Write a standalone .svg instead of printing |
--preview | — | Write an HTML preview at 240/64/33/23px |
Workflow
Always run with --preview, then screenshot it in headless Chrome and look:
python3 "${CLAUDE_SKILL_DIR}/trace.py" art.png --preview /tmp/p.html > /tmp/path.txt
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless --disable-gpu \
--screenshot=/tmp/p.png --window-size=420,300 --force-device-scale-factor=3 \
--hide-scrollbars file:///tmp/p.htmlThe preview deliberately shows tiny sizes. A trace that looks great at 240px routinely turns to grain at 23px, and that is usually the size that matters.
Expect two or three tuning passes. Judge each by the preview, not by the numbers.
Tuning, in the order that pays
- Resolution beats file format. A higher
--sizeseparates shapes that fuse at low resolution and sharpens fine detail; 720 does this markedly better than 360. Format matters much less than people expect, because downscaling averages compression noise away. - But trace the original, not a re-export. A lossy re-export blurs exactly the low-contrast boundaries the threshold depends on — and exports are often downsampled too, which compounds it. Ask for the source file.
- There is a ceiling. Past a point, more resolution just adds speckle that turns to noise at icon size. Test one step up; if it comes back busier rather than better, stay put.
--min-holekills speckle. Too low and dozens of pinholes survive as grain. Raise it until only meaningful openings remain.--cropbefore anything else if the image has a background, a second subject, or a part you don't want. Watch for cropping through the subject — it leaves a hard straight edge that reads as a mistake.--thresholdis the judgement call on shaded art. Pencil and airbrush work are continuous-tone, so there's no correct cutoff — try 200 / 215 / 230.
Using the result
const ART = 'M25.6 1.8 L...'; // paste the traced path
<svg viewBox="0 0 32 32" aria-hidden="true">
<path d={ART} fill="currentColor" fillRule="evenodd" />
</svg>Because it's one path tinted by currentColor, one trace serves every colour
variant. transform="translate(32 0) scale(-1 1)" mirrors it — useful when two
variants must stay distinguishable without relying on colour.
Budget roughly 7–13 KB of path data at --simplify 2.4. Raise --simplify to
shrink it; that costs fine detail first.
Limits
- macOS only (
sips). - Wants a drawing on a light background with a mostly closed outline. Photos, busy backgrounds, and subjects touching the image border all fail — crop first, or expect the flood fill to leak inward and swallow the figure.
- Output is a filled silhouette with holes. It is not stroke-preserving line art; thin strokes below roughly 1.5px at the target size vanish.
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
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.

