Trace an image to clean SVG
trace_iconConverts a raster icon or logo image into a clean, editable SVG with real colour shapes and fitted curves, auto-choosing mono or colour, gradients and resolution.
Instructions
Vectorize a raster image into a clean, editable SVG: colour regions become real shapes with fitted curves, not a traced outline of pixels. Decides colour vs mono, gradient fitting and trace resolution automatically (override with the options). Writes the .svg and reports path count, node count and the decisions it made.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"image": "<image>"
},
"name": "trace_icon"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ink | No | Paint a MONO trace in this instead of the ink the probe read: a hex colour, or "currentColor" so the icon takes the CSS text colour (what an icon set wants). Colour traces keep their colours. | |
| out | No | Where to write the SVG. Default: next to the source, same name, .svg extension (<name>.traced.svg when the source is itself that .svg, so it is never overwritten). | |
| mode | No | auto (default) counts the inks: one ink on paper traces mono, which is far cleaner for line art; anything else traces colour. | |
| image | Yes | Path to the image to trace (PNG, JPEG, WebP, GIF, BMP, or an SVG to re-trace). | |
| inset | No | With normalize: units kept clear on each side. Default size/12 (2 on a 24 grid, as Lucide draws). | |
| quiet | No | Return only the summary (one line per icon for a sheet) and skip the JSON block. For batches, where the JSON repeats what the summary says. | |
| detail | No | high lifts the flat-art raster cap 2048 → 4096: crisper, ~4x the work. | |
| inline | No | Also return the SVG markup in the response (only do this for small icons). | |
| search | No | Check the automatic choices instead of trusting them: trace the choices left on auto (mono vs colour, gradients on vs off) each way, score every candidate against the image (mean ΔE), and keep the automatic pick unless another candidate is clearly closer. A forced mode or gradients is kept. About 2.5x slower (one full trace per candidate). The plan reports every candidate’s score. Default on; false keeps the automatic pick untested. | |
| strokes | No | Trace LINE ART as centreline strokes with a measured stroke-width (open and closed stroked paths you can re-weight), instead of filled outlines of each line. Ink no stroke explains (a dot, a note head) still becomes a fill. In colour mode each stroke is painted in the ink it runs through. Default off. | |
| fidelity | No | Shape-beautification tolerance in px; 0 disables snapping to circles/lines. | |
| layering | No | Colour mode. stacked (default): a shape paints under the shapes in front of it — fewer nodes, no hairline seams between colours, shapes stay whole in a design tool. tiled: shapes fit edge to edge, with a hole wherever another sits inside. Same edges either way; mono ignores it. | |
| despeckle | No | 0 keeps every speck, 100 is aggressive. Default 25. | |
| gradients | No | auto (default) probes for real colour ramps. flat forces solid fills (right for most icons). rich forces gradient fitting. | |
| normalize | No | Refit the SVG into a square viewBox of this many units: normalize: 24 fits the art into "0 0 24 24", centred, with `inset` units clear on every side, coordinates rounded to 2 decimals — so every icon of a set shares one grid. Stroke widths scale with it. Omit to keep the viewBox at the traced pixel size. | |
| smoothing | No | 0 = crisp and node-dense, 100 = smooth and sparse. Default 50. | |
| flattenOnto | No | Composite a TRANSPARENT source onto this colour before tracing, e.g. "#ffffff". Omit to keep the alpha. (Not the card colour — that is appearance.background.) | |
| strokesOnly | No | With `strokes`: NO filled paths at all — the ink no stroke explains (a dot, a note head, a solid shape) is drawn as round-capped strokes too, along its own middle and as wide as it is there; a dot is a round-capped point. Nothing is dropped, but a shape that is not a line is approximated (a square comes back with round ends). For plotters and stroke-only icon sets. Default off. | |
| removeBackground | No | Drop the detected background layer so the SVG comes back transparent. |