Image Overlay: RGBA on RGB
RGBA on RGB — the pack's actual compositing workhorse
- Background(RGB)
- Foreground(RGBA)
- image
This is the node you reach for the moment you've cut a subject out and need to actually put it somewhere. You've run a background remover, you've got a clean transparent cutout, and now you want it sitting on a new background - a product shot, a poster, a scene. ComfyUI doesn't have a stock "paste this on top of that" node with opacity control, so KGnodes ships one, and it's simple enough that you'll wonder why it isn't core.
How it works
Two images in, one out. The background is plain RGB. The foreground can be RGBA (with real transparency, like whatever a BiRefNet or RMBG cutout gave you) or plain RGB - if it's RGB, the node just fabricates an alpha channel for it based on whatever opacity you dial in. Either way, the foreground's alpha is what actually drives the blend: fully opaque pixels replace the background outright, fully transparent pixels leave it untouched, and everything in between gets mixed proportionally. That's standard alpha compositing, nothing exotic, but having it as a dedicated node with an opacity slider saves you from hand-rolling it with a handful of math nodes.
One hard requirement, straight from the README: background and foreground have to be the exact same height and width. The node doesn't resize anything for you. If your cutout came off a different-sized source than your background, resize one of them first - the pack's own Rescale Image To Side node or ComfyUI's stock resize will do it.
The inputs and outputs that matter
Background(RGB)- your base image, no alpha needed.Foreground(RGBA)- the thing being pasted on top. RGBA or RGB both work.Foreground Opacity(0–1, default 1) - how strong the overlay is. At 1 it's a full paste; dial it down for a ghosted watermark or a soft double-exposure look.Output Mode-RGBorRGBA. PickRGBif you're about to save the image or feed it into something that doesn't expect an alpha channel (most samplers and preview nodes). PickRGBAif you need to keep compositing further down the graph - say, layering a second overlay on top of this result.
Output is a single image, and the node is flagged as an output node, so it'll happily terminate a branch of your graph on its own.
How to install it
Search KGnodes in ComfyUI Manager, or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/shahkoorosh/ComfyUI-KGnodes.git
pip install -r requirements.txt
Restart ComfyUI. The whole pack lives under Add Node → 🎨KG, so this shows up as "Image Overlay: RGBA on RGB" in that submenu. No models to download - it's pure image math, so it's fast and doesn't touch your GPU meaningfully.
Common issues & troubleshooting
Size mismatch errors. This is the one that'll actually stop you. The README is explicit that foreground and background must match in height and width - batch dimension included if you're feeding batches. If you're pairing this with a background-removal cutout, that cutout is the same size as whatever photo you fed the remover, which is almost never the same size as your new background. Resize first, composite second.
Foreground looks "hard-edged" even with a real alpha mask. Check your source. If whatever produced your RGBA foreground gave you a binary (0 or 255) alpha instead of a soft gradient - some quick-and-dirty segmentation masks do this - you'll get a cutout-and-paste look instead of a blended one, no matter what you set Foreground Opacity to. That's an upstream mask-quality problem, not this node misbehaving.
Output looks washed out or wrong when chained further. If you set Output Mode to RGBA and then feed the result into a node that doesn't understand an alpha channel, you can get weird results or an outright type error. Default to RGB unless you specifically need the alpha carried forward.
RGB foreground doesn't look like it's blending. Remember: with an RGB foreground, the "alpha" is synthetic - it's just your opacity value applied uniformly across every pixel. There's no per-pixel transparency to preserve because there was never any transparency data to begin with. If you need edge-aware blending (soft hair, fuzzy fabric), you need a real RGBA foreground with a real alpha channel, not this node inventing one for you.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| Background(RGB) | IMAGE | — | |
| Foreground(RGBA) | IMAGE | — | |
| Foreground Opacity | FLOAT | 1.000–1 | — |
| Output Mode | COMBO | RGB | 2 options: RGB, RGBA |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |