SVG Rasterizer (Simple)
Render SVG Text at Any Resolution, Border Included
- image
SVG Rasterizer (Simple) (class RasterizeSVG) is the second half of the ComfyUI-Svg2Raster pack, and honestly the more interesting one. It takes SVG text - either pasted in, or piped from the pack's Load SVG Image node - and renders it to a raster image at whatever size you want. The "simple" in the name is doing a lot of work: the whole point is that a vector at 512px and a vector at 2048px come out equally crisp, because the render happens from the geometry, not from upscaling pixels. Logos, icons, masks, ControlNet conditioning shapes - anything you want sharp and resolution-independent.
How it works
Under the hood it's CairoSVG calling svg2png on your text, then a short pass through Pillow to add the border and hand ComfyUI an RGBA image tensor. The input you'll actually touch:
svg_text(STRING, multiline) - the SVG markup. The default is a little green circle, so you can hit Run on a fresh node and immediately see it work. That's a nice touch for a utility node.width(INT, default 512, max 4096) - the output width in pixels. Height follows automatically to preserve aspect ratio.scale(FLOAT, default 1.0, 0.1–20) - a pure scale factor. Only applies ifwidthis 0.background_color(STRING, defaulttransparent) - hex#RRGGBBortransparent. Fills in wherever the SVG has no pixels.border_width(INT, default 0) andborder_color- adds a border around the whole rendered image.
The width vs scale interplay is the one rule to remember: a non-zero width beats scale. Set width and scale is ignored; set width to 0 and scale takes over. For most people, set width to your target and never think about scale again. And since the output is a plain image (IMAGE), it drops into any preview, VAE encoder, or ControlNet preprocessor slot like any other raster.
Installing it
Identical to the pack's other node, and the gotcha is the same one:
- Install Cairo as a system dependency before anything else - CairoSVG won't work without the native library. Linux:
apt install libcairo2-dev pkg-config; macOS:brew install cairo; Windows: the Cairo/GTK runtime from cairographics.org. - Install via ComfyUI Manager (search "ComfyUI-Svg2Raster"), or:
cd ComfyUI/custom_nodes git clone https://github.com/garg-aayush/ComfyUI-Svg2Raster.git pip install -r requirements.txt # cairosvg, pillow, numpy - Restart ComfyUI. It shows up under FromSVG/Tools with
Load SVG Image.
No models, no keys - just Cairo plus three small Python packages.
Where people get burned
Cairo is the usual suspect: Manager installs the Python side and everything looks fine until runtime, then CairoSVG dies because the system library is missing. A surprising number of node authors treat Cairo as a pain point worth avoiding - you'll even see SVG nodes that exist purely to not use it. If you hit a Cairo error, that's the fix.
Two color gotchas specific to this node. Color fields are strict: #RRGGBB hex or the word transparent, and nothing else - no red, no #f00 shorthand. It validates with a regex and throws a ValueError telling you the format if you stray. And if you render with a transparent background, you get an RGBA image with real alpha - great for compositing, but some downstream nodes expect opaque input and will do odd things with a transparent canvas. If that happens, set background_color to a hex value and carry on.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_text | STRING | <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'><circle cx='128' cy='128' r='96' fill='#22c55e'/></svg> | — |
| width | INT | 5120–4096 | — |
| scale | FLOAT | 1.00.1–20 | — |
| background_color | STRING | transparent | — |
| border_width | INT | 00–1024 | — |
| border_color | STRING | transparent | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |