Convert SVG → IMG (+colors)
The return trip from vector to pixels
- svg_text
- image
- mask
- colors_json
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 withopen_subpaths_pxto 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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_text | SVG_TEXT | — | |
| widthopt | INT | 51216–4096 | — |
| scale_in_canvasopt | FLOAT | 1.000.1–2 | — |
| transparent_bgopt | BOOLEAN | false | — |
| background_hexopt | STRING | #000000 | — |
| pad_pxopt | INT | 00–512 | — |
| keep_alpha_as_maskopt | BOOLEAN | true | — |
| stroke_onlyopt | BOOLEAN | false | — |
| open_subpaths_pxopt | INT | 00–512 | — |
| rendereropt | COMBO | auto | 3 options: auto, native, cairosvg |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| colors_json | STRING | — |