Prévisualisation SVG
Rasterize your SVG back into a real image tensor
- svg_text
- IMAGE
SVG is text. ComfyUI works with tensors. SVG Preview is the node that makes those two worlds talk: it rasterizes any SVG_TEXT into an IMAGE tensor using CairoSVG - a proper rendering engine, not a toy. It's the "look at what my vector workflow built" node, and it's also the bridge for anything that needs your vector as pixels: feeding it to a diffusion model as a control input, compositing it over a raster image, or just saving a PNG preview for a client.
How it works
The node renders the SVG to a PNG in memory with cairosvg.svg2png(), then converts that to a ComfyUI IMAGE tensor. The clever part is fit_mode: before rendering, it parses the SVG's viewBox to learn the aspect ratio, then picks the render size accordingly:
- stretch - fills the exact width×height you set, distorting the aspect ratio if they differ.
- fit_width - width fixed, height derived from the aspect ratio.
- fit_height - height fixed, width derived.
- contain - fits the whole drawing inside your width×height while preserving aspect ratio.
That last one is usually what you want: no cropping, no distortion, the drawing just fits.
Inputs that matter
svg_text- the source SVG.width,height(defaults 512×512, up to 4096) - the output canvas.fit_mode- the aspect-ratio behavior above.bg_enabled+bg_color_hex- if on, the render gets an opaque background color; if off, the image keeps its transparency as RGBA.
If svg_text is empty, the node renders a blank canvas of your chosen color - handy for testing, easy to mistake for a bug.
Outputs
A single IMAGE output. Wire it to a preview node, Save Image, or anywhere else that wants pixels.
How to install
Part of the orion4d/ComfyUI_DAO_master pack. This node hard-requires CairoSVG - the class refuses to initialize without it (ImportError: CairoSVG est requis), so it's not optional:
cd ComfyUI/custom_nodes
git clone https://github.com/orion4d/ComfyUI_DAO_master.git
pip install cairosvg lxml
Restart ComfyUI. No models. (CairoSVG is a pure-Python wrapper over Cairo; on some systems the underlying Cairo shared library needs to be present, which is the usual source of "installed but still broken".)
Common issues
The red node with "CairoSVG est requis" is the classic: you installed the pack but cairosvg isn't in ComfyUI's Python environment. Install it and restart. If rendering works but everything looks letterboxed oddly, you're on stretch with a mismatched canvas - switch to contain. And if transparency isn't showing up, bg_enabled is on; turn it off to get RGBA out.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_text | SVG_TEXT | — | |
| width | INT | 51264–4096 | — |
| height | INT | 51264–4096 | — |
| fit_mode | COMBO | 4 options: stretch, fit_width, fit_height, contain | |
| bg_enabled | BOOLEAN | false | — |
| bg_color_hex | STRING | #FFFFFF | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |