Nodes/ComfyUI-ToSVG/Image to SVG String BW_Potracer
ComfyUI Node

Image to SVG String BW_Potracer

Potrace, the engine behind decades of vector logos

By Yanick112·Created 2 years ago·Updated about a year ago· 313
Image to SVG String BW_Potracer
  • image
  • STRING
â—„threshold128â–º
â—„input_foregroundBlack on Whiteâ–º
â—„turnpolicyminorityâ–º
â—„turdsize2â–º
â—„corner_threshold1.00â–º
â—„zero_sharp_cornersfalseâ–º
â—„opttolerance0.20â–º
â—„optimize_curvetrueâ–º
â—„foreground_color#000000â–º
â—„background_color#FFFFFFâ–º
â—„stroke_color#FF0000â–º
â—„stroke_width0.0â–º

Everyone in this pack talks about VTracer, but this node runs a different engine: Potrace. That's the tracing library with serious pedigree - the same one behind GIMP's bitmap-to-vector conversion and a whole generation of logo autotracers. The pack added this node in the June 17 update, with an integration credited to ImagineerNL.

Why would you want Potrace when VTracer is already here? Two engines, two characters. Potrace is battle-tested at exactly one job: turning clean black-and-white bitmaps into crisp, compact vector line art. For logos, stencils, signatures, and engraving - the stuff where you want a tight outline and no argument about intermediate colors - Potrace is the classic, and it's harder to beat than people expect. VTracer is the modern generalist; Potrace is the specialist.

The inputs that matter

Required: image and threshold (0–255, default 128) - the brightness cut that decides shape vs. background. Everything else is optional, and most of it you'll leave alone:

  • input_foreground - Black on White (default) or White on Black. Tell it which way your source is oriented; getting this backwards inverts your shape.
  • turnpolicy - minority, black, white, left, right, majority. This is the classic Potrace knob for how winding paths resolve ambiguous corners. minority is the sane default; touch it only if you see weird edge artifacts.
  • turdsize - default 2. Minimum speck size to keep; raise it to drop noise.
  • corner_threshold (0–1.34, default 1.0) and zero_sharp_corners - corner detection. Enable zero_sharp_corners and it pins the threshold to 1.34 for the sharpest corners.
  • opttolerance (0–1, default 0.2) and optimize_curve - how aggressively the path is optimized. Leave on.
  • foreground_color, background_color, stroke_color, stroke_width - it builds the SVG by hand, so you can color the result without touching a text editor. stroke_width 0 means no stroke (plain fill).

One notable quirk: this node returns a single STRING - the whole batch joined with newlines - where the VTracer nodes return a list of strings. Feed a single image and you won't notice; feed a batch and downstream nodes expect one string.

How it works

It binarizes your image against threshold, inverts it for Black-on-White input, runs potrace.Bitmap(...).trace(...) with your settings, and hand-assembles the SVG path data - you can see the bezier segment math in the source. It also guards every step: blank images and processing failures come back as a tiny SVG with an error message in a <desc> tag instead of a crash. That's genuinely thoughtful error handling for a batch workflow.

Getting the best out of it

Potrace rewards clean input. Run TS_ImageQuantize down to 2–3 colors or a hard threshold first, keep the resolution decent, and it'll produce line art that looks like a human drew it. Then simplify with TS_SVGPathSimplify if the file's heavy.

Install

Same pack, same install. ComfyUI Manager → search ComfyUI-ToSVG → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Yanick112/ComfyUI-ToSVG/
cd ComfyUI-ToSVG
pip install -r requirements.txt

Dependencies include potracer (the maintained Potrace fork) plus vtracer, numpy, Pillow, torch, PyMuPDF. No models, no API keys, all local. If fitz import fails after an update, reinstall PyMuPDF - that's the usual conflict when node packs fight over the shared Python environment.

Category💎TOSVG/Convert

Inputs (13)

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—
background_coloroptSTRING#FFFFFF—
stroke_coloroptSTRING#FF0000—
stroke_widthoptFLOAT0.0—

Outputs (1)

NameTypeDescription
STRINGSTRING—