Nodes/ComfyUI-ToSVG/SVG String Preview
ComfyUI Node

SVG String Preview

Look at your trace before you commit to saving it

By Yanick112·Created 2 years ago·Updated about a year ago· 313
SVG String Preview
      SVG_String

      TS_SVGStringPreview is the current version of the pack's preview node (renamed from SVGPreview in the June 17 update). It answers the question that comes up within thirty seconds of tracing your first image: "what did that actually look like?" - because SVG is just text, and you can't eyeball text.

      It's an output node with one input: SVG_String. It rasterizes the SVG, renders it as a PNG, and shows it in the ComfyUI UI. That's it. And that's exactly what makes it worth having.

      How it works

      The rasterization goes through PyMuPDF (fitz): fitz.open(stream=SVG_String, filetype="svg"), render the page with get_pixmap(), convert the PNG bytes to a PIL image, then to a tensor. The tensor gets handed to ComfyUI's standard SaveImage machinery - which is why the node description says it saves images to your output directory - except it's pointed at the temp folder with a random per-session prefix, so previews stay out of your real output collection.

      One thing to keep in mind: the preview is a rasterization at PyMuPDF's default resolution, so it's a faithful-but-not-huge representation of your SVG. It'll show you whether the trace is clean or speckled, but it won't show you the crispness of the actual vector file. Trust the preview for shape and noise; trust the saved SVG for final quality.

      Where it fits

      The tuning loop is the killer use case. Instead of guessing at corner_threshold, filter_speckle, and friends and saving four files to check, run: image → converter → this node. Adjust a slider, re-run, look again. When it looks right, swap the preview for TS_SaveSVGString and save for real. You can also drop it after TS_SVGPathSimplify to check whether a simplification pass wrecked the shapes.

      Install

      Same pack, same install as everything in ComfyUI-ToSVG. 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: vtracer, numpy, Pillow, torch, PyMuPDF, potracer. No models, no API keys, CPU-only. If PyMuPDF ever fails to import after updating another node pack, reinstall it - conflicting versions of fitz in the shared Python environment are the classic cause.

      Category💎TOSVG/Tools

      Inputs (1)

      NameTypeDefaultDescription
      SVG_StringSTRING

      Outputs (0)

      No outputs