ComfyUI Node

SVG Rasterizer

SVG Rasterizer re-draws the vector at 6144px instead

By jaisurya-dev-art·Created 20 days ago·Updated 12 days ago· 0
SVG Rasterizer
  • svg
  • image
  • mask
◄width6144►
◄height6144►
◄backgroundwhite►

The job nobody's upscaler can do

Most "make it bigger" requests in ComfyUI fall into two buckets: more pixels (Lanczos, ESRGAN, the NVIDIA path) or more detail (SeedVR2, tile ControlNet - generation that will cheerfully rewrite a face). There's a third case that fits neither: flat art. A silhouette, a logo, an icon, a sticker cut, a line drawing. Nothing to invent, nothing to interpolate - the shape has no resolution limit. It's geometry pretending to be a bitmap.

That's what SVG Rasterizer is for. It takes the native SVG value ComfyUI's tracing nodes emit and renders it directly at whatever resolution you ask for - 6144 × 6144 by default, up to 16384. No low-res intermediate, no Pillow resize, no AI pass.

How it works

The pack is a thin, honest wrapper around resvg_py, a Rust SVG renderer. It hands your SVG text to resvg_py.svg_to_bytes(svg_string=…, width=…, height=…), gets PNG bytes back, loads them with Pillow, and splits the result in two: RGB becomes IMAGE (float32, 0–1, [B, H, W, 3]), alpha becomes MASK (float32, 0–1, [B, H, W], where 1 is fully covered).

resvg honors the SVG's own viewBox and preserveAspectRatio, so a non-square drawing isn't stretched to your canvas: if the result comes back short on one axis, the code centers it on a transparent canvas - placement, not resize. An oversized result is an error rather than a silent crop. Batches render per item and stack, so both outputs carry a matching leading dimension.

One detail, because it's the part that usually breaks: the socket is typed SVG, not STRING. ComfyUI represents that as a wrapper whose .data holds one BytesIO per batch item, and this node reads it directly (bytes, text, file-likes and data/svg/content mappings also work). A string node wired in fails type checking before anything runs.

The inputs you actually touch

  • svg - wire it from the tracing node. Nothing else to set.
  • width / height - 64 to 16384, default 6144. Set these to your final export size; rendering at 2048 and scaling later defeats the point.
  • background - white (default), black, or transparent. white/black composite the SVG over a solid fill, which is what you want for black-on-white silhouettes. transparent leaves the RGB uncomposited and hands coverage to the MASK output.

That last option is the one people get wrong. ComfyUI's IMAGE has no alpha channel, so transparent doesn't give you a see-through PNG - it gives you the raw RGB plus a mask describing the shape. Want real transparency in the file? Take the mask output and composite with it downstream. Save Image alone won't do it.

Installing it

Manager (search "SVG Rasterizer") or the Comfy Registry entry, or just:

cd ComfyUI/custom_nodes
git clone https://github.com/jaisurya-dev-art/ComfyUI-SVG-Rasterizer

then restart ComfyUI. No model download, and no GTK, Cairo or Rust toolchain to assemble - resvg_py ships prebuilt wheels. The dependencies are three lines - resvg_py, pillow, numpy - and on first load the pack checks for them and pip-installs requirements.txt using the exact Python running ComfyUI. That's why it works out of the box on Portable; it also means the first launch needs internet, and progress or failure prints to the server console, not the UI.

If the auto-install can't run - offline machine, a distro Python that refuses pip into the system environment, a venv mismatch - the node still loads, then fails at run time with a resvg_py is unavailable message. Fix it by hand in ComfyUI's environment:

python_embeded/python.exe -m pip install -r ComfyUI/custom_nodes/ComfyUI-SVG-Rasterizer/requirements.txt

Where it bites

The trace sets the ceiling, not the rasterizer. Rendering at 16384 doesn't add detail the tracer threw away. A photo traced to SVG becomes flat color islands with blocky path edges, and this node renders those edges at enormous resolution, perfectly crisply - which looks worse than a normal upscale. Flat art only.

Memory scales nastily. 6144 × 6144 float32 RGB is ~450 MB before the mask, and the mask is another ~150 MB - per image. Batch four at the default size and you're holding over 2 GB of tensors. Iterate at 2048, render at full size once the art is right.

The loop it lives in

Trace → rasterize → save. Whatever produced the SVG - a Potrace-family node, Image-to-SVG, ComfyUI's own SVG tooling - feeds this socket. The version that earns its keep pairs it with background removal upstream: cut the subject, trace the alpha, render a clean 6144 px silhouette, ship it. Icons and logos are where this pipeline makes sense, and it's a small corner of r/comfyui - nobody argues about it because almost nobody has bothered to build it.

Reach for SVG Rasterizer when the output is line art, and a generative upscaler when it isn't. Get that wrong and you end up with a beautifully sharp rasterization of a badly traced photo.

CategorySVG

Inputs (4)

NameTypeDefaultDescription
svgSVG—
widthINT614464–16384—
heightINT614464–16384—
backgroundCOMBOwhite3 options: transparent, white, black

Outputs (2)

NameTypeDescription
imageIMAGE—
maskMASK—