AddBackgroundNode
Slap the right color behind your ID photo without touching the face
- input_img
- normal_params
- IMAGE
HivisionNode hands you a cutout with a transparent background. AddBackgroundNode is what turns that cutout into a photo that reads as "blue background" or "white background" - which, for ID photos, is most of the battle. It's the step between the matting pipeline and the print/layout stage, and it's the node in this pack that does one job and does it cleanly.
How it works
No model, no download, instant. The node takes the 4-channel RGBA portrait, splits it into color and alpha, and composites each pixel against the chosen background using the classic (pixel - bg) * alpha + bg blend. The background itself comes from normal_params:
bgcolor- the hex color, one of six (blue, white, red, black, dark blue, light gray).render-pure_coloris a flat fill;updown_gradientandcenter_gradientare procedural gradients in that same color, generated on the fly. No gradient image to find or download.
Because it's a straight alpha blend, the edges you fought for in the matting step survive. Fine hair that MODNet or BiRefNet managed to keep stays believable against the new background - which is exactly what the background-removal playbook says to watch for: a cutout that looks fine on a grey preview can fall apart against a colored background, and this node shows you the final answer immediately.
The input that matters
input_img- this is where people get burned. It must be an RGBA image. Wire it fromHivisionNode'sstandard_imgorhd_img(both keep alpha), not from a plainLoadImagenode - a normal 3-channel image makes the node's channel-split throw "the input image must have 4 channels." The shipped workflow feedshd_imgin, which is a good default since it's the higher-res one.normal_params- the same PARAMS bundle that flows to every node in the pack. You don't set color here, you set it on the params node upstream.
Output
A single IMAGE - now opaque, 3-channel after the composite. That feeds straight into AddWaterMarkNode (also in this pack), LaterProcessNode for file-size control, HivisionLayOutNode for the print sheet, or a SaveImage if you just want the finished single photo.
Installing it
Same pack as everything here, so it arrives with the rest. Via ComfyUI Manager (search "HivisionIDPhotos") or:
cd ComfyUI/custom_nodes
git clone https://github.com/AIFSH/HivisionIDPhotos-ComfyUI
Restart ComfyUI after. This node itself needs nothing beyond the pack's shared opencv-python/numpy requirements - the weight downloads that HivisionNode demands are irrelevant to it, since it does pure image math.
Troubleshooting
- "must have 4 channels" error - you fed it a 3-channel image. Re-wire from
HivisionNode, not from LoadImage. - Background is white regardless of what you picked - check which params node is upstream and whether
bgcoloractually changed. All four consumer nodes share one PARAMS wire; if you created a second params node for the background, the rest of the chain won't see it. - The gradient modes look flat - the gradients are subtle by design, a gentle falloff rather than a dramatic wash. If you want a strong directional light feel, this node isn't that tool; it's built for regulation-clean backgrounds.
One more honest note: the pack has been dormant since September 2024, but this node is so small and so dependent only on OpenCV that it's the least likely thing in the pack to break on you.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input_img | IMAGE | — | |
| normal_params | PARAMS | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |