Image to SVG String BW_Potracer
Potrace, the engine behind decades of vector logos
- image
- STRING
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) orWhite 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.minorityis 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_width0 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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| threshold | INT | 1280–255 | — |
| input_foregroundopt | COMBO | Black on White | 2 options: White on Black, Black on White |
| turnpolicyopt | COMBO | minority | 6 options: minority, black, white, left, right, majority |
| turdsizeopt | INT | 2 | — |
| corner_thresholdopt | FLOAT | 1.000–1.34 | — |
| zero_sharp_cornersopt | BOOLEAN | false | — |
| opttoleranceopt | FLOAT | 0.200–1 | — |
| optimize_curveopt | BOOLEAN | true | — |
| foreground_coloropt | STRING | #000000 | — |
| background_coloropt | STRING | #FFFFFF | — |
| stroke_coloropt | STRING | #FF0000 | — |
| stroke_widthopt | FLOAT | 0.0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |