转换SVG丨图像
Bringing your vectorized line art back into the graph
- image
- mask
- width
- height
This is the node that closes the loop. The rest of the TJ_ComfyUI_Lineart2Vector pack turns a line-art image into an SVG string - a text blob only other SVG nodes can eat. SVG To Image rasterizes that string back into a real IMAGE tensor, so you can actually see what you made, or feed it straight back into the image side of your graph (ControlNet, img2img, a VAE encode, whatever). If you're vectorizing line art to throw it back into another generation pass, this is your bridge node.
The honest catch first
The name oversells it a little. This is a basic path renderer built on Pillow (ImageDraw), not a full SVG engine. The README is upfront about it: it understands simple path commands - M, L, H, V, C, Z - plus stroke/fill colors and line/polygon drawing. Gradients, filters, clip paths, advanced path syntax? Nope. Complex SVGs will come out wrong or missing elements. For those, the README's answer is the workhorse combo: save with SVG File Saver and render in Inkscape, Illustrator, or your browser - or, on Linux/macOS, install CairoSVG, which the pack's Python info node is literally designed to help you debug (more on that in its own article).
So think of this node as a preview-and-recycle tool, not a production renderer. That's fine - it's what most people need inside ComfyUI anyway.
Inputs that matter
svg_string- the SVG you got from Centerline to SVG or any editor node in the pack.width/height- set to0(the default) to auto-size from the SVG's own dimensions, or force a pixel size.scale- output multiplier, 0.1–8×. Handy for rendering big, sharp versions.background- transparent, white, black, or custom (withbackground_color, default#00000000).dpiandpadding- mostly for tweaking output sizing and margins.
The useful optional overrides: override_stroke_color, override_fill_color (empty string = keep the original colors), override_stroke_width (0 = keep original), and show_control_points - draws square markers at path control points so you can see the underlying geometry. antialias defaults on, and clip_to_viewbox keeps everything inside the SVG's viewBox.
Outputs: image (the IMAGE you wire onward) and meta (a JSON string with render stats).
Installing the pack
Via ComfyUI Manager, search TJ_ComfyUI_Lineart2Vector. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/TJ16th/TJ_ComfyUI_Lineart2Vector.git
# restart ComfyUI
No model downloads, no API keys - it's all local image/SVG math. The requirements.txt pulls in numpy, Pillow, opencv-python, opencv-contrib-python (that second one is the easy one to miss), scikit-image, scipy, and torch. Almost all of those ship with ComfyUI already, so a fresh install is usually just the clone + restart.
Where people get burned
- The renderer is silent about what it can't do. A complex SVG won't error - it'll just render partially, so don't trust a clean run as proof your SVG survived. Spot-check with a real viewer.
- If a parse fails, the node draws the error text into the image rather than throwing - which is actually handy, but it means "weird text image" = your SVG string wasn't valid.
- On Windows there's no cairosvg fallback at all (it needs native DLLs), so the Pillow renderer is the only in-graph option. Accept it or take the file-saver route.
For a beginner, the flow that works: vectorize → SVG Group Layout to eyeball the paths → File Saver for the real export → and SVG To Image only when you genuinely need a raster version back in the graph.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_input | STRING | <svg width='100' height='100' xmlns='http://www.w3.org/2000/svg'><rect width='100' height='100' fill='red'/></svg> | — |
| adjust_size | STRING | 1024 | — |
| keep_aspect_ratio | COMBO | true | 2 options: true, false |
| scale_definition | COMBO | longest_side | 5 options: longest_side, shortest_side, width, height, total_pixels |
| scale_method | COMBO | lanczos | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest |
| dpi | INT | 10010–1200 | — |
| output_format | COMBO | png | 2 options: png, jpg |
| quality | INT | 951–100 | — |
| background_color | STRING | — | |
| multiple_ofopt | INT | 00–256 | — |
| target_pixelsopt | INT | 1048576256–16777216 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| width | INT | — |
| height | INT | — |