ComfyUI Node

Potracer to SVG

Turn any 2-color image into a clean SVG, locally, with no API key

By ImagineerNL·Created about a year ago·Updated about a year ago· 26
Potracer to SVG
  • image
  • svg_string_deprecated
  • svg_ComfyUI_v0.3.32+
threshold128
input_foregroundBlack on White
turnpolicyminority
turdsize2
corner_threshold1.00
zero_sharp_cornersfalse
opttolerance0.20
optimize_curvetrue
foreground_color#000000
stroke_color#ff0000
stroke_width0.0
background_color#ffffff
no_backgroundfalse
output_scale1.0

The name is not a lie: this node traces an image into a real vector SVG on your own GPU-less machine. No API, no key, no credit card, no uploading your logo to someone else's server. If you've ever compared the result to a paid tool like Vectorizer.ai and thought "why can't I just do that," this is the closest free thing - because it literally runs the same classic algorithm (Potrace, via Tatarize's pure-Python potracer port) that those tools are built on.

PotracerVectorize ("Potracer to SVG") lives in the ImagineerNL/ComfyUI-ToSVG-Potracer pack, a one-person passion project aimed squarely at vinyl cutters and logo work. Its sibling, Yanick112's ComfyUI-ToSVG, uses VTracer - great for multicolor, detailed images. This node is the opposite: it only understands two colors, a foreground and a background. That's not a limitation so much as the point. Potrace turns a clean black-and-white mark into one smooth compound path with far fewer vector points than a VTracer trace, which matters when you're cutting vinyl or loading a logo into Illustrator/Silhouette Studio and don't want to spend an hour cleaning up stray points.

How it works

The pipeline is short. Your IMAGE tensor gets binarized - every pixel brighter than threshold becomes one side, darker becomes the other (so any non-pure image gets forced to black-and-white). That bitmap goes into potrace.Bitmap, gets traced with your tuning parameters, and the node hand-builds the SVG: one <path> with fill-rule="evenodd" so internal holes render correctly, plus an optional background rectangle.

A couple of things worth knowing before you touch the knobs:

  • input_foreground - tells the node whether your image is black-on-white or white-on-black. Get this wrong and your shape inverts into its own background.
  • threshold (default 128, 0–255) - the brightness cutoff. This is the control you'll actually fiddle with. Crank it up or down until the trace matches your image's edges.
  • turdsize - suppresses specks up to N pixels. Default 2 kills most noise; raise it if your trace is full of little islands.
  • zero_sharp_corners - forces every corner fluid by setting the backend's corner threshold to 1.34. The author swears by it for vinyl.
  • opttolerance and optimize_curve - curve optimization. More tolerance = fewer points, at some cost to fidelity. optimize_curve on by default is fine.
  • Colors: foreground_color, background_color (or no_background to drop the bg rect entirely), plus optional stroke_color/stroke_width if you want an outline instead of a solid fill.
  • output_scale - multiplies the output coordinates, width and height. Handy if your SVG needs to be bigger without re-tracing.

Outputs

Two of them, and which one you use depends on your ComfyUI version:

  • svg_string_deprecated (STRING) - the raw SVG markup as text. This is the old route: wire it into Yanick112's SaveSVG node.
  • svg_ComfyUI_v0.3.32+ (SVG) - a typed SVG object that plugs straight into the built-in SaveSVG node that ComfyUI 0.3.32+ ships with. This is the route for new setups; no extra packages needed.

Install

Either via ComfyUI Manager (search ComfyUI-ToSVG-Potracer) or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ImagineerNL/ComfyUI-ToSVG-Potracer
cd ComfyUI-ToSVG-Potracer
pip install -r requirements.txt   # or your portable python

The real gotcha is in requirements.txt: it installs potracer and explicitly warns that pypotrace / pypotrace-windows must be uninstalled first - the two packages fight over the potrace module name. If the node shows an error widget instead of inputs, that's almost certainly what happened; check your console and pip uninstall pypotrace pypotrace-windows. No model files to download, by the way - the dependency is one pure-Python library.

If you go the old string route, you also need Yanick112's ComfyUI-ToSVG installed (the README says "latest version") for its SaveSVG and VectorToRaster nodes.

Gotchas

The pack history is a good warning to read before it bites you. Version 1.2 switched its output from a list to a single string to match Yanick112's node - if an old workflow suddenly stops connecting, update both packages. And the author's honest advice about input images: don't bother upscaling your source; it rarely helps and usually makes the trace worse. Spend the effort on contrast - clean up a JPEG with a contrast/brightness node instead, and the trace follows.

Feed it a photo and you'll get a muddy mess, because that's not what Potrace does. Give it a clean high-contrast mark and it genuinely rivals the paid converters. First public node from a hobbyist, so expect the rough edges - but for logo-to-SVG in a ComfyUI workflow, it's the one I reach for.

CategoryIMGNR

Inputs (15)

NameTypeDefaultDescription
imageIMAGE
thresholdINT1280–255
input_foregroundoptCOMBOBlack on White2 options: White on Black, Black on White
turnpolicyoptCOMBOminority6 options: minority, black, white, left, right, majority
turdsizeoptINT2
corner_thresholdoptFLOAT1.000–1.34
zero_sharp_cornersoptBOOLEANfalse
opttoleranceoptFLOAT0.200–1
optimize_curveoptBOOLEANtrue
foreground_coloroptSTRING#000000
stroke_coloroptSTRING#ff0000
stroke_widthoptFLOAT0.0
background_coloroptSTRING#ffffff
no_backgroundoptBOOLEANfalse
output_scaleoptFLOAT1.00.1–100

Outputs (2)

NameTypeDescription
svg_string_deprecatedSTRING
svg_ComfyUI_v0.3.32+SVG