Nodes/ComfyUI-OllamaGemini/Gemini Convert Raster to Vector
ComfyUI Node

Gemini Convert Raster to Vector

Image-to-SVG tracing (no Gemini involved)

By al-swaiti·Created 2 years ago·Updated 2 months ago· 185
Gemini Convert Raster to Vector
  • image
  • svg_strings
colormodecolor
modespline
filter_speckle4
color_precision8
corner_threshold80
length_threshold2.00
max_iterations15
splice_threshold45
path_precision5
optimizetrue

Ignore the "Gemini" in the name - this node doesn't call any AI model and needs no API key. It carries the prefix because it ships in the ComfyUI-OllamaGemini pack. What it does: convert a raster image into an SVG by tracing it, using vtracer (the node's own description says so, "for best quality"). It's how you turn a generated pixel image into scalable vector paths without leaving ComfyUI.

It's essentially the same node as the pack's Raster to Vector (SVG) (ConvertRasterToVector), with one addition: an optimize toggle. Same tracing engine, same knobs, one extra switch.

Why you'd reach for it

Vectors are what you want for logos, icons, and flat art you'll scale or recolor. Open-source diffusion models all output pixels - the only image generator that produces vectors natively is the closed, paid Recraft V3 (per the knowledge base). So in an open workflow, tracing is the route to SVG: generate the art, then convert it here.

How it works

vtracer clusters regions of similar color and fits paths around them. It has no semantic understanding of the picture, which is exactly why it shines on flat, limited-color art and falls apart on photos - trace a photorealistic render and you get thousands of paths and a huge file. Feed it clean, bold, few-color graphics and it's excellent.

The inputs that matter

The ones worth setting:

  • colormode - color for full color, binary for a single-color silhouette.
  • mode - spline for smooth curves (default), polygon for hard straight edges.
  • filter_speckle (default 4) - removes clusters below this pixel size; the go-to dial for killing noise.
  • color_precision (default 8) - number of color levels kept; lower it to posterize and shrink the file.
  • optimize (default on) - this node's extra toggle, which cleans up and simplifies the output SVG. Leave it on unless you're debugging path output.

The remaining dials (corner_threshold, length_threshold, max_iterations, splice_threshold, path_precision) fine-tune curve smoothing and joining; the defaults are good.

The output is svg_strings, a LIST of SVG text - not a viewable image. Pass it to the pack's Gemini Save SVG node to write the .svg and get a rendered preview.

Installing it

Install the ComfyUI-OllamaGemini pack via ComfyUI Manager (search the name, install, restart) or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
pip install -r requirements.txt

then restart. It depends on the vtracer Python package from requirements.txt; if the node throws an import error at run time, that dependency didn't install - re-run the pip install in the pack folder.

Where people get burned

Don't trace photos. Vectorization is for flat graphics; on a photorealistic image it produces a massive, path-heavy file that looks worse than the source. Generate art meant to be flat - strong shapes, limited palette - or posterize first.

Also remember this node emits SVG strings, so nothing appears until you route them through Gemini Save SVG. When edges come out ragged, raise filter_speckle and lower color_precision before touching the threshold dials. And since this is the twin of Raster to Vector (SVG) with only the optimize switch added, there's no reason to run both - pick this one if you want that extra optimization pass, the other if you don't.

CategoryAI API

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
colormodeCOMBOcolor2 options: color, binary
modeCOMBOspline2 options: spline, polygon
filter_speckleINT40–20
color_precisionINT81–16
corner_thresholdINT800–180
length_thresholdFLOAT2.000.5–10
max_iterationsINT151–50
splice_thresholdINT450–180
path_precisionINT51–10
optimizeBOOLEANtrue

Outputs (1)

NameTypeDescription
svg_stringsLIST