4.7 KiB
ComfyUI Vectorizer & Background Remover Pack This repository contains a pack of two powerful nodes for ComfyUI designed to automate a professional vector-based image processing pipeline. Convert raster images to clean, scalable vectors using the Vectorizer.AI API, and then perfectly remove the background for compositing and further creative work.
This pack is ideal for automating the creation of character sprites, icons, logos, and other graphic assets.
✨ Core Features High-Quality Vectorization: Integrates with the powerful Vectorizer.AI API to convert PNGs into clean, editable SVGs.
Infinite Scalability: Includes a scaled_png option to render the resulting SVG at any resolution (e.g., 4x, 8x) for crisp, high-resolution raster images without quality loss.
Automatic Background Removal: A smart "green screen" node that automatically detects and removes any solid color background. No AI guessing, just precise, controllable results.
Mask Output for Advanced Workflows: The background remover provides a perfect black and white silhouette mask, ideal for inpainting, compositing, sticker effects, and driving ControlNets.
Secure & Convenient: Supports API key management via an optional config.json file, so you don't have to enter your credentials in the workflow.
📦 Nodes Included
- Vectorizer.ai API This node is the bridge to the Vectorizer.AI service. It takes an image and sends it for vectorization.
Inputs: image, API credentials, output_format (svg, png, scaled_png), mode (production or test), and other vectorization parameters.
Output: Returns the original or processed IMAGE back into the workflow.
Functionality: Saves the final vector (.svg) or raster (.png) file to your ComfyUI output directory, respecting your filename_prefix and numbering.
- Background Remover (Color) A fully automatic chroma keyer designed for images with a solid color background.
Inputs: image, threshold (to control the edge softness/fuzziness).
Outputs: image_rgba (the subject on a transparent background) and mask (the black and white silhouette).
Functionality: Intelligently detects the background color by analyzing the image borders, making it perfect for automated pipelines where the background color might vary slightly between images.
⚙️ Installation
Activate your venv then proceed to following these instructions:
Clone the Repository Navigate to your ComfyUI custom_nodes directory and clone this repository:
cd ComfyUI/custom_nodes/ git clone https://github.com/rickrender/ComfyUI-Vectorizer-Pack.git
Install Python Dependencies Install the required Python packages using the included requirements.txt file.
cd ComfyUI-Vectorizer-Pack pip install -r requirements.txt
Install System Dependencies (for CairoSVG) The scaled_png feature relies on the Cairo graphics library. You must install it on your system.
For Debian/Ubuntu you may need an alternative package:
sudo apt-get update && sudo apt-get install libcairo2-dev pkg-config
For other operating systems, please consult their package manager to install the "Cairo" library.
Set Up API Credentials (Recommended) Create an account at vectorizer.ai and get your keys from here: https://vectorizer.ai/account For convenience, create a file named config.json inside the ComfyUI-Vectorizer-Pack folder. Add your API keys to this file:
{ "api_id": "YOUR_REAL_API_ID", "api_secret": "YOUR_REAL_API_SECRET" }
The node will automatically use these credentials if the fields in the UI are left blank. You can also enter them in the UI if you wish instead.
Restart ComfyUI Completely restart your ComfyUI instance. The new nodes will appear in the "Conversion" category.
workflow Example Here is a simple, powerful pipeline to go from a generated character to a clean, transparent asset.
Generate Image: Use your preferred method to generate a character on a solid color background.
Vectorize & Scale: Connect the generated image to the Vectorizer.ai API node.
Set output_format to scaled_png.
Set scale to your desired multiplier (e.g., 4.0).
Remove Background: Connect the IMAGE output from the Vectorizer node to the Background Remover (Color) node.
Adjust the threshold slider (a value around 0.3 to 0.4 is often a good start) to get a clean edge with minimal color halo.
Save Final Image: Connect the image_rgba output from the remover node to a Save Image node. Ensure you use a format that supports transparency, like PNG.
(Optional) Use the Mask: Connect the mask output to other nodes to perform inpainting, create outlines, or for advanced compositing.
Dependencies Python: requests, CairoSVG
System: libcairo2 or equivalent
License This project is licensed under the MIT License.
Acknowledgements This node pack utilizes the powerful Vectorizer.AI service.