Gemini SVG Preview
Turn SVG code into a ComfyUI image
- svg_strings
- IMAGE
ComfyUI thinks in pixels. Every node passes around raster IMAGE tensors, and there's no native way to look at a piece of SVG markup inside the graph. This node fixes exactly that one problem: hand it SVG code as text, and it rasterizes it into an IMAGE you can preview, save, or feed into the rest of your workflow. The node's own description says it plainly - "Preview SVG data as an image with improved rendering."
Why it exists
It's a bridge node, and it only makes sense once you see the other half of the pack. The OllamaGemini pack can point an LLM (Gemini, Claude, GPT, whatever) at a request like "draw me a flat-icon logo," and language models are surprisingly decent at emitting valid SVG - it's just structured text, which is their home turf. But that SVG is a string. You can't save it as a PNG, you can't run it through an upscaler, you can't composite it. GeminiSVGPreview is what turns that string back into something the rest of ComfyUI understands. Vector in, raster out.
Outside that pairing it's still useful any time you've got SVG from somewhere - a template, a generated logo, an icon - and you want it on the canvas as an image.
How it works and what you set
The node takes SVG markup and draws it onto a raster canvas at a size you choose. Three inputs, and only two you'll think about:
svg_strings- the SVG markup itself. It's typed as a list, so it can rasterize a batch of SVGs in one go, not just a single one. This is usually wired from whatever produced the SVG rather than typed by hand.widthandheight- the pixel dimensions of the output canvas. Both default to 512 and range from 64 up to 2048.
The output is a single IMAGE, which goes straight into a Save Image node, a Preview Image, or any downstream step. Because it's a normal raster image at that point, you can upscale it, composite it, or run it through anything else in your graph.
The one thing to internalize: width and height set the canvas, not the SVG's own proportions. SVGs are resolution-independent, so this node is picking a resolution to freeze them at. Set 512×512 for a wide banner SVG and you'll get letterboxing or a squish depending on how the SVG's own viewBox is defined. Match the aspect ratio of the artwork and bump the numbers up - 1024 or 2048 - if you want crisp edges, since a vector re-rastered too small throws away the whole point of it being a vector.
Installing it
ComfyUI Manager: search ComfyUI-OllamaGemini, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
pip install -r requirements.txt
then restart. Don't skip the pip install step here - SVG rasterization isn't something Python does out of the box. It needs a rendering library (the cairosvg / cairo family, or an equivalent), and that comes in through the pack's requirements.txt. If that install step half-finishes, this node is one of the first to break.
Where people get burned
Two failure modes, both real. First, the rasterizer dependency. If the node loads but every output comes back blank, tiny, or errors on execute, the SVG-rendering library didn't install cleanly - check the ComfyUI console at startup for an import error mentioning cairo or svg. This is the OllamaGemini dependency-hell problem in miniature: it's a big pack with a lot of Python dependencies, and the ones with native system libraries behind them are the ones that fail quietly. Second, malformed SVG. An LLM will occasionally emit SVG that's almost valid - an unclosed tag, a namespace it forgot - and the rasterizer either renders garbage or nothing. If the preview is blank but the node didn't error, paste the SVG string into any browser or online SVG viewer to confirm it's actually valid before you blame the node. Nine times out of ten the fix is upstream, in whatever generated the markup.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_strings | LIST | — | |
| width | INT | 51264–2048 | — |
| height | INT | 51264–2048 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |