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

SVG String to Image

Rasterize an SVG string back into a ComfyUI image

By Yanick112·Created 2 years ago·Updated about a year ago· 314
SVG String to Image
    • IMAGE
    ◄SVG_String—►

    TS_SVGStringToImage is the pack's return trip: it takes an SVG string and turns it back into a standard IMAGE tensor. If you already read the page for ConvertVectorToRaster, this is its current name - same node, renamed in the June 17 update, same one-input-one-output shape. Come for the rename note, stay for the mechanism, because the mechanism explains a real limitation people trip over.

    How it works

    It hands the SVG string to PyMuPDF (fitz): fitz.open(stream=SVG_String, filetype="svg"), renders the first page to a pixmap, converts those pixels to PNG bytes, opens them as a PIL image, and returns a tensor. It's the same rasterization path the preview node uses - this one just hands you the IMAGE instead of painting it on the canvas.

    Here's the thing to internalize: there's no resolution control. The output is whatever PyMuPDF's default pixmap DPI gives you. SVG is resolution-independent until you rasterize it; the moment it crosses this node it's locked to a fixed, fairly modest pixel grid. Fine for previewing, compositing, and feedback loops. Wrong tool for "final high-res export" - for that, save the SVG itself with TS_SaveSVGString and let whatever consumes it render at its own scale.

    Inputs and outputs

    • SVG_String - SVG markup, straight from a converter like TS_ImageToSVGStringBW_Vtracer or the color variant.
    • Output: IMAGE, ready for any image-side node.

    Where it earns its keep

    The feedback loop, mostly: vectorize, rasterize back, and compare the trace against your original generation side by side. That's how you tune corner_threshold and filter_speckle without saving a file every run. It also lets you push a vectorized result back through the pixel pipeline - composite a traced logo over a scene, run it through another pass, upscale it, whatever your graph does with images.

    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: vtracer, numpy, Pillow, torch, PyMuPDF, potracer. No models, no API keys, CPU-only. PyMuPDF is the one to babysit: it's a compiled dependency that other packs pin to different versions, so a fitz import failure after an update is usually fixed by reinstalling PyMuPDF into the same Python environment.

    Category💎TOSVG/Convert

    Inputs (1)

    NameTypeDefaultDescription
    SVG_StringSTRING—

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE—