Nodes/ComfyUI_DAO_master/Convert SVG → IMG (+colors)
ComfyUI Node

Convert SVG → IMG (+colors)

The return trip from vector to pixels

By orion4d·Created about a year ago·Updated 12 months ago· 11
Convert SVG → IMG (+colors)
  • svg_text
  • image
  • mask
  • colors_json
width512
scale_in_canvas1.00
transparent_bgfalse
background_hex#000000
pad_px0
keep_alpha_as_masktrue
stroke_onlyfalse
open_subpaths_px0
rendererauto

So you traced an image to SVG, or generated text as a vector, or imported some paths - now what? ComfyUI's samplers don't eat SVG. Convert SVG → IMG is the return trip: it rasterizes SVG text back into an image, hands you a matching mask, and throws in a colors_json report of what it found. It's the node that closes the loop in the pack's vector pipeline, and it's the one that lets you go pixels → vector → tweak → pixels without ever leaving ComfyUI.

It's from orion4d/ComfyUI_DAO_master, the French-authored vector-and-utility pack. The useful trick this one adds over a plain SVG renderer is a real color analysis pass - you can read the detected palette off the colors_json string and use it to drive other nodes.

How it works

You feed it svg_text (the SVG_TEXT type the pack's other SVG nodes output - it's effectively a string holding raw SVG markup). Internally it parses the document with ElementTree, resolves paths through svgpathtools, and converts geometry to Shapely polygons so it can handle fills, strokes, transforms, and even stroke_only / open-subpath cases that naive renderers mangle.

The renderer selector is the interesting bit: auto (default) tries the built-in native rasterizer first, then falls back to cairosvg if the native pass came out suspiciously empty (it checks pixel coverage against the background). If you have cairosvg installed you can force it with renderer = cairosvg, which is great for SVGs that use advanced features the native parser can't handle.

Key inputs:

  • width - output width in pixels (16–4096, default 512); height is derived from aspect ratio.
  • scale_in_canvas - zoom the drawing inside the output canvas (0.1–2×).
  • transparent_bg + background_hex - transparent canvas or a solid fill color.
  • keep_alpha_as_mask - export the alpha channel as the mask output.
  • stroke_only - render only strokes, skipping fills; pairs with open_subpaths_px to fatten open paths so they stay visible.

Outputs: image (IMAGES), mask (MASK), and colors_json - a JSON string listing detected colors and shapes, which you can parse downstream or just eyeball in a text preview node.

Installing

Via ComfyUI Manager (search ComfyUI_DAO_master) or:

cd ComfyUI/custom_nodes
git clone https://github.com/orion4d/ComfyUI_DAO_master.git

For full functionality install the SVG deps and restart:

pip install cairosvg svgpathtools lxml shapely

Where people get burned

The svg_text input only accepts the pack's SVG_TEXT type - a plain STRING from a text node won't connect, so if you have SVG as a raw string, run it through the pack's SVG Passthrough node first. And while auto is a decent safety net, SVGs with heavy <use> references, external hrefs, or exotic filters may render blank or partial with the native engine - that's your cue to force cairosvg.

CategoryDAO_master/SVG/Convert

Inputs (10)

NameTypeDefaultDescription
svg_textSVG_TEXT
widthoptINT51216–4096
scale_in_canvasoptFLOAT1.000.1–2
transparent_bgoptBOOLEANfalse
background_hexoptSTRING#000000
pad_pxoptINT00–512
keep_alpha_as_maskoptBOOLEANtrue
stroke_onlyoptBOOLEANfalse
open_subpaths_pxoptINT00–512
rendereroptCOMBOauto3 options: auto, native, cairosvg

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
colors_jsonSTRING