5.2 KiB
ComfyUI Vectorizer & Background Remover Pack
This repository contains a pack of useful nodes for ComfyUI designed to simplify a professional vector-based image processing pipeline. Convert raster images to clean, scalable vectors using the Vectorizer.AI API, and then remove the background with a background removal node for compositing and further creative work. There are options to scale the vector graphic to a user defined value, this can allow for higher resolution raster graphics without quality loss.
✨ Core Features
- High-Quality Vectorization: Integrates with the powerful Vectorizer.AI API to convert PNGs into clean, editable SVGs.
- Infinite Scalability: Includes a
scaled_pngoption 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.jsonfile, so you don't have to enter your credentials in the workflow.
📦 Nodes Included
1. 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(productionortest), and other vectorization parameters. - Output: Returns the original or processed
IMAGEback into the workflow. - Functionality: Saves the final vector (
.svg) or raster (.png) file to your ComfyUIoutputdirectory, respecting yourfilename_prefixand numbering.
2. 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) andmask(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 by following these instructions:
-
Clone the Repository
Navigate to your ComfyUI
custom_nodesdirectory and clone this repository:cd ComfyUI/custom_nodes/ git clone https://github.com/rickrender/ComfyUI-Vectorizer-API.git -
Install Python Dependencies
Install the required Python packages using the included
requirements.txtfile.cd ComfyUI-Vectorizer-API pip install -r requirements.txt -
Install System Dependencies (for CairoSVG)
The
scaled_pngfeature relies on the Cairo graphics library. You must install it on your system.- For Debian/Ubuntu:
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.
- For Debian/Ubuntu:
-
Set Up API Credentials (Recommended)
Create an account at vectorizer.ai and get your keys from your account page. For convenience, create a file named
config.jsoninside theComfyUI-Vectorizer-Packfolder. 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.
Example Usage
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 APInode.- Set
output_formattoscaled_png. - Set
scaleto your desired multiplier (e.g.,4.0).
- Set
- Remove Background: Connect the
IMAGEoutput from the Vectorizer node to theBackground Remover (Color)node.- Adjust the
thresholdslider (a value around0.3to0.4is often a good start) to get a clean edge with minimal color halo.
- Adjust the
- Save Final Image: Connect the
image_rgbaoutput from the remover node to aSave Imagenode. Ensure you use a format that supports transparency, like PNG. - (Optional) Use the Mask: Connect the
maskoutput to other nodes to perform inpainting, create outlines, or for advanced compositing.
Dependencies
- Python:
requests,CairoSVG - System:
libcairo2or equivalent
License
This project is licensed under the MIT License.
Acknowledgements
This node pack utilizes the powerful Vectorizer.AI service.