Smart Color Fill Mask
Paint any hex color into a mask region
- image
- mask
- color
- IMAGE
There's a surprisingly common chore in ComfyUI that has no clean built-in answer: "paint a solid color inside this mask area." Maybe you want a red censor bar over a region, a white backdrop where the subject used to be, or a flat color mat you can composite behind something. Smart Color Fill Mask is that answer - feed it an image, a mask, and a hex color, and it replaces the masked region with your color.
How it works
The logic is a one-liner in spirit: wherever the mask is 1.0, blend in the color; wherever it's 0.0, keep the original pixels. The node parses the hex color (#RRGGBB), and per frame it linearly mixes original * (1 - mask) + color * mask. On RGBA images it leaves the alpha channel untouched - it repaints the RGB channels but doesn't disturb transparency, which is usually what you want and easy to forget when you're wiring things up.
Two details matter:
invert_mask- flips which side gets filled. Leave it off and the white parts of the mask become your color. Flip it and the black parts get filled instead. This saves you from adding an invert node half the time.- Batch handling - if your mask has fewer frames than the image batch, it reuses the last mask rather than erroring, and it resizes the mask to match the image if the dimensions disagree.
Inputs and outputs
image- theIMAGEto paint on.mask- theMASKdefining the fill region (1.0 = fill with color).invert_mask- boolean, default off.color- a hex color widget, default#FFFFFF.
Output: one IMAGE with the color applied.
Installing it
It's part of the ComfyUI-SmartImageTools pack:
cd ComfyUI/custom_nodes
git clone https://github.com/slvslvslv/ComfyUI-SmartImageTools
pip install -r ComfyUI-SmartImageTools/requirements.txt
Restart ComfyUI, or grab "SmartImageTools" via ComfyUI Manager. No models, no keys - just the pack's shared numpy/OpenCV stack.
Where it fits, and where it doesn't
The cleanest uses are flat-fill jobs: color cards, mattes, censorship bars, or clearing a region to a known color before inpainting. The mask can come from anywhere - SmartImageRegion in this pack makes a quick rectangle mask you can feed straight in, which turns "paint a rectangle red" into a two-node graph with zero fiddling.
One honest limitation: it only fills with a solid hex color. No gradients, no soft feathering beyond what's already in your mask (though a blurred mask will give you a soft edge, since the mix is linear). And if your color has alpha in mind, note the node keeps the existing alpha and only touches RGB - for a color with its own transparency, that's the wrong tool.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| invert_mask | BOOLEAN | false | — |
| color | COLOR | #FFFFFF | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |