ConvertWhiteToAlpha
Cheap white-background removal when you don't need a model
- pixels
- skip
- color
- IMAGE
- BOOLEAN
You don't need a 500MB background-removal model for every cutout. If your source is a clean white-background image - a logo, line art, a UI screenshot, an icon, a sticker - the fastest possible "remove background" is: any pixel that's white becomes transparent. That's ConvertWhiteToAlpha. It's a blunt instrument with zero VRAM cost, and for flat graphics it beats every segmentation model in the pack because there's nothing to segment.
How it works
It walks the image and any pixel whose red, green and blue are all above a whiteness threshold (~239/255, so near-white, not pure #FFFFFF) gets its alpha channel zeroed; everything else stays opaque. The optional color input is the interesting twist: if you hand it a dict like {"r": 255, "g": 0, "b": 0}, it recolorizes the kept pixels to that color while keeping them fully opaque - handy for tinting monochrome art as you convert it. The skip input is a bypass: wire anything truthy in and the node hands your original pixels back untouched, so a branch that already has alpha can skip the conversion.
One thing to know about the color and skip inputs: they're typed as wildcards (*), so ComfyUI won't stop you from wiring a text or number in. The code expects a dict for color - treat it as "pass a small map node's output here", not a hex string. The BOOLEAN output simply echoes whatever skip received, so you can branch on whether it actually converted.
Where it fits
The KB's background-removal essay is blunt about the tradeoff: this class of threshold approach is what you use when speed and determinism beat edge quality. ConvertWhiteToAlpha is that, taken to its extreme - it's for graphics with a guaranteed white background, not photographs with a white wall. Hair, soft shadows, JPEG artifacts around the subject? It'll punch holes in all of them. Use a real remover (BiRefNet and friends) for photography; reach for this when you want a logo composited onto a colored scene and you want it done in microseconds.
Installing it
It's in the petty-paint pack:
cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node
Restart ComfyUI after, or install via ComfyUI Manager by searching "petty-paint-comfyui-node". Only declared dependency is Flask==2.1.2.
Common issues
Where people get burned: ComfyUI's IMAGE tensors are RGB, so the 4-channel RGBA result can get its alpha silently dropped by downstream nodes - check that whatever you feed the result into actually keeps the alpha channel before you celebrate. Also, the output is a list of images (it processes each frame in the batch), so some nodes will want an index or a flattening step. And if your input has a soft gradient to white, the hard threshold will leave a visible fringe - that's physics, not a bug; pre-flatten the background if it matters.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| skipopt | * | — | |
| coloropt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| BOOLEAN | BOOLEAN | — |