Nodes/Bjornulf_custom_nodes/๐Ÿ–ผ+๐Ÿ–ผ Stack two images (Background+Overlay alpha)
ComfyUI Node

๐Ÿ–ผ+๐Ÿ–ผ Stack two images (Background+Overlay alpha)

Composite a transparent overlay onto a background

By justUmenยทCreated 2 years agoยทUpdated about a year agoยท 545
๐Ÿ–ผ+๐Ÿ–ผ Stack two images (Background+Overlay alpha)
  • background
  • overlay
  • mask
  • image
  • mask
โ—„horizontal_position50.0โ–บ
โ—„vertical_position50.0โ–บ

This is a simple compositing node: it stacks one image (the overlay) on top of another (the background) and lets you position the overlay wherever you want. The overlay is meant to have transparency - think a subject with the background removed, dropped onto a new scene. In the pack's menu it's the "Stack two images (Background + Overlay)" node.

It's the classic "put this cutout on that background" move. Pair it with a background-removal node (rembg, BiRefNet, or the pack's own Green Screen to Transparency) upstream, and this is what places the result.

How it works

You feed it a background and an overlay. The overlay's alpha channel decides what shows through, and the two position sliders decide where it lands. The positions are expressed as percentages that run from โˆ’50 to 150, which sounds odd until you realize it lets you push the overlay partly (or fully) off the edges of the background - 50/50 is dead center, 0/0 is up and to the left, 100/100 is down and to the right, and negative or >100 values slide it off-frame. There's also an optional mask input if you want to control the overlay's transparency explicitly rather than relying on its baked-in alpha.

One limitation the author flags: the background is treated as a single static image. You can run video frames through the overlay side by sending all the frames, but don't expect a moving background here.

The inputs and outputs that matter

  • background - the base image.
  • overlay - the image placed on top, ideally with transparency.
  • horizontal_position and vertical_position - where the overlay sits, as percentages from โˆ’50 to 150 (default 50 each = centered). This is the pair you'll actually tune.
  • mask (optional) - an explicit MASK to control what of the overlay shows through.

Outputs are image (the composite) and mask (the resulting mask), so you can chain further compositing if needed.

How to install it

ComfyUI Manager: search Bjornulf_custom_nodes, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/justUmen/Bjornulf_custom_nodes

Restart ComfyUI. This is a pure image operation and doesn't need the pack's heavy dependencies, though installing requirements.txt is fine if you'll use other nodes.

Common issues

The big one: if your overlay has no real transparency, you'll just see it slapped as an opaque rectangle over the background. Make sure whatever produced the overlay actually preserved an alpha channel - and note that ComfyUI's default Load Image node strips transparency, so use the pack's "Load Image with Transparency" node (or feed the mask input) if the overlay looks like a solid block.

If the overlay lands in the wrong spot or partly off-screen, that's the โˆ’50 to 150 percentage scale doing its thing; nudge the two position sliders back toward 50. And remember the background is static - for a moving-background composite you'll need a different approach.

CategoryBjornulf

Inputs (5)

NameTypeDefaultDescription
backgroundIMAGEโ€”
overlayIMAGEโ€”
horizontal_positionFLOAT50.0-50โ€“150โ€”
vertical_positionFLOAT50.0-50โ€“150โ€”
maskoptMASKโ€”

Outputs (2)

NameTypeDescription
imageIMAGEโ€”
maskMASKโ€”