home / skills / openclaw / skills / trace-to-svg

trace-to-svg skill

/skills/ajmwagar/trace-to-svg

This skill converts bitmaps to clean SVG paths using mkbitmap and potrace, enabling scalable silhouettes and logo workflows for CAD-ready outlines.

npx playbooks add skill openclaw/skills --skill trace-to-svg

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.3 KB
---
name: trace-to-svg
description: Trace bitmap images (PNG/JPG/WebP) into clean SVG paths using potrace/mkbitmap. Use to convert logos/silhouettes into vectors for downstream CAD workflows (e.g., create-dxf etch_svg_path) and for turning reference images into manufacturable outlines.
metadata:
  openclaw:
    requires:
      bins: ["potrace", "mkbitmap"]
    install:
      - id: apt
        kind: apt
        package: potrace
        bins: ["potrace", "mkbitmap"]
        label: Install potrace + mkbitmap (apt)
      - id: brew
        kind: brew
        formula: potrace
        bins: ["potrace", "mkbitmap"]
        label: Install potrace + mkbitmap (brew)
---

# trace-to-svg

Convert a bitmap into a vector SVG using `mkbitmap` + `potrace`.

## Quick start

```bash
# 1) Produce a silhouette-friendly SVG
bash scripts/trace_to_svg.sh input.png --out out.svg

# 2) Higher contrast + less noise
bash scripts/trace_to_svg.sh input.png --out out.svg --threshold 0.6 --turdsize 20

# 3) Feed into create-dxf (example)
# - set create-dxf drawing.etch_svg_paths[].d to the SVG path `d` you want, or
# - store the traced SVG and reference it in your pipeline.
```

## Notes

- This is best for **logos, silhouettes, high-contrast shapes**.
- For photos or complex shading, results depend heavily on thresholding.
- Output is usually one or more `<path>` elements.

Overview

This skill converts bitmap images (PNG, JPG, WebP) into clean SVG paths using mkbitmap and potrace. It produces silhouette-friendly vector output suitable for CAD and manufacturing pipelines. Use it to turn logos, high-contrast shapes, or reference images into precise SVG outlines ready for downstream tools.

How this skill works

The tool first applies mkbitmap to produce a clean monochrome bitmap using adjustable thresholding and noise filtering. Then potrace traces the bitmap into one or more optimized SVG path elements. Output options let you tune threshold and turdsize to control detail and remove small artifacts.

When to use it

  • Converting logos or icons into scalable vector outlines for engraving or cutting.
  • Preparing silhouettes and high-contrast shapes for CNC, laser, or vinyl workflows.
  • Generating manufacturable outlines to feed into a create-dxf or etch_svg_path stage.
  • Quick tracing of reference artwork when a clean vector source is unavailable.
  • Removing small speckles and smoothing contours before CAD conversion.

Best practices

  • Start with a high-contrast, tightly-cropped input image to improve trace accuracy.
  • Adjust threshold to balance missing detail vs. noisy regions; higher threshold reduces shading artifacts.
  • Increase turdsize to remove small isolated specks that become unwanted paths.
  • Inspect resulting SVG path 'd' values and simplify or combine paths in an editor if needed.
  • Use traced SVG as an intermediate: keep the original raster and the SVG for iterative tuning.

Example use cases

  • Trace a company logo PNG to produce a single SVG path for laser etching.
  • Convert a silhouette photo into a clean outline for CNC cutting with create-dxf.
  • Generate vector outlines of product artwork to import into CAM or CAD software.
  • Batch-trace high-contrast icons to produce a library of scalable assets for fabrication.

FAQ

Will this work on detailed photos?

Photos with complex shading rarely trace cleanly; results depend on thresholding and may require pre-processing or manual cleanup.

What do threshold and turdsize control?

Threshold controls the binarization level for mkbitmap; turdsize removes small isolated regions to reduce noise in the final SVG.

How do I use the SVG with CAD tools?

Extract the SVG path 'd' or store the traced SVG file, then feed it into create-dxf or your CAD import workflow to generate toolpaths or DXF outlines.