Background Remover (Shape)
Background Remover (Shape)
- image_rgba
- mask
- modified_svg_data
What it actually is
This is the vector-domain sibling of the pack's color remover, and it's the more interesting one of the two. Instead of keying on color, it takes the svg_data string straight off the Vectorizer.ai API node, removes the single largest shape - usually the background of a vectorized illustration - and re-renders the cleaned SVG into an RGBA image plus a mask. Because it works on the geometry rather than the pixels, it doesn't care whether the backdrop is white, black, or plaid. No color sampling, no threshold to tune.
The one assumption it leans on: for a vectorized image, the background is one dominant shape. That holds beautifully for the flat illustrations this pack is aimed at, and it's why this node slots directly after the VectorizerAINode in the example workflow.
How it works
Under the hood it parses the SVG with lxml, walks every <path> element, estimates each one's bounding-box area from its coordinates, and deletes the largest. Then CairoSVG re-renders the result at your scale (default 4), which is where the quality comes from - you keep working on the vector, so you can rasterize at 4x or 8x with clean edges instead of upscaling pixels.
Two inputs are required: svg_data (a STRING with forceInput, so you must wire it from the Vectorizer.ai API node's svg_data output) and scale. Optionally save_svg and filename_prefix write the cleaned SVG to your output directory. It returns three outputs: image_rgba, the mask, and - the one to save if you want the actual vector - modified_svg_data, the edited SVG text itself.
Installing it
Same pack as the other two nodes, so one install covers everything. ComfyUI Manager: search "Vectorizer API", install, restart. Or by hand:
cd ComfyUI/custom_nodes/
git clone https://github.com/rickrender/ComfyUI-Vectorizer-API
cd ComfyUI-Vectorizer-API
pip install -r requirements.txt
The requirements are requests, lxml, and CairoSVG. Note that unlike the color remover, this node needs both lxml and cairosvg to do anything at all, and cairosvg needs the system Cairo library on top (sudo apt-get install libcairo2-dev pkg-config on Debian/Ubuntu).
Where people get burned
- Silent blank output. If either
lxmlorcairosvgis missing, the node returns a blank 128x128 image and mask and logs a warning at import. Your graph "runs"; you get nothing. Check the console. - Only
<path>elements count. The background is assumed to be a path. If the SVG's backdrop came out as a<rect>, a circle, or a group, this node won't see it as a shape at all and won't remove it. - "Largest shape" is by bounding box, not fill. A border frame that wraps the entire artwork has the biggest bounding box on the canvas and can get deleted in place of the actual background. Inspect
modified_svg_datawhen results look wrong. - It's tuned for this pack's vectorizer output. Hand-made SVGs with dozens of overlapping shapes give unpredictable results - reach for it when you've just vectorized, not when you're editing a designer's file.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| svg_data | STRING | — | |
| scale | FLOAT | 4.01–16 | — |
| save_svgopt | BOOLEAN | true | — |
| filename_prefixopt | STRING | SVG/vector_edited | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image_rgba | IMAGE | — |
| mask | MASK | — |
| modified_svg_data | STRING | — |