Extract production-ready SVG icons from raster images (screenshots, UI mockups, design comps) using browser-based precision cropping and automated vector tracing...
This skill converts raster icons (from screenshots, mockups, or design files) into clean, mathematically smooth SVG vector paths. It solves the common problem where naive potrace tracing produces jagged or artifact-filled results on real-world UI images.
The pipeline works in two phases:
Before running this skill, verify the following are installed:
# Check potrace (required for vector tracing)
which potrace || echo "MISSING: Install with 'brew install potrace' (macOS) or 'apt-get install potrace' (Linux)"
# Check Python Pillow (required for image processing)
python3 -c "from PIL import Image; print('Pillow OK')" || echo "MISSING: Install with 'pip install Pillow'"
If either is missing, install them before proceeding. Do not skip this step.
In all commands below, $SKILL_DIR refers to the directory containing this SKILL.md file.
Run generate-cropper with the source image and a list of icon names to extract:
python3 "$SKILL_DIR/scripts/svg-tools.py" generate-cropper /path/to/image.png icon_name_1 icon_name_2
What this does:
crop.html file in the current directoryWhat to tell the user:
crop.html in a browser<icon_name>_precise.pngDo not proceed to Step 2 until the user confirms all crops are saved.
Once the user has all _precise.png files, run trace:
python3 "$SKILL_DIR/scripts/svg-tools.py" trace ~/Downloads/icon_name_1_precise.png ~/Downloads/icon_name_2_precise.png
What this does:
potrace to produce optimized SVG outputOutput: <icon_name>.svg files in the same directory as the inputs.
Read each generated .svg file, extract the <path d="..."> data, and inject it into the target codebase (React components, HTML templates, etc.).
| Problem | Cause | Fix |
|---|---|---|
| SVG has jagged edges | Crop was too loose, included background noise | Re-crop more tightly around the icon |
| SVG is blank or all-black | Icon was too light or too colorful for the threshold | The image needs a dark-on-light icon; adjust source |
potrace: command not found |
potrace not installed | brew install potrace or apt-get install potrace |
ModuleNotFoundError: PIL |
Pillow not installed | pip install Pillow |