Nodes/Kaizen Package/Image Composite
ComfyUI Node

Image Composite

Mask compositing that doesn't hate off-canvas

By aleolidev·Created about a year ago·Updated about a year ago· 0
Image Composite
  • background
  • foreground
  • mask
  • composite
x0
y0

The name undersells it. KaizenImageComposite (shown as "Image Composite") pastes one image onto another using a mask, at any x/y you want - including coordinates that put the overlay partly or fully outside the canvas. It's the paste step at the end of a thousand workflows: after background removal, after an inpaint pass, after you cut a subject out with SAM or GroundingDino and want it sitting on a fresh scene.

ComfyUI already ships ImageCompositeMasked, which does 80% of this job, so the honest question is whether Kaizen's version earns a slot on your graph. The pitch: five inputs, one output, and a mask that's silently resized to match your foreground instead of the other way around. It's a slim, boring alternative - and for the paste-back step, boring is usually what you want. The trade is that it's deliberately minimal. No feathering, no blur, no "paste only the masked region from a third image." If you need those, reach for WAS Node Suite's blend utilities or stick with core.

How it works

Under the hood it's a plain alpha blend: the mask controls how much foreground vs. background shows at each pixel (foreground × alpha + background × (1 − alpha)). The interesting part is the bounds handling. It computes the intersection between the foreground rectangle at (x, y) and the background canvas, clips both the source and the mask to that overlap, and blends only there. If the overlay doesn't touch the canvas at all, you get the background back unchanged - no error, no garbage pixels. That's the whole reason negative coordinates are safe here.

One thing worth knowing from the source: it operates on the first frame of each input only. Feed it an animation batch and frames 1, 2, 3… are ignored entirely.

The inputs that matter

  • background / foreground - the IMAGEs being composited.
  • mask - a MASK where 1.0 is opaque foreground and 0.0 is transparent. If its size doesn't match the foreground, it's auto-resized to fit.
  • x, y - position of the foreground's top-left corner, from −4096 to 4096. Negative values push the overlay off the top or left edge.

The single output, composite, is an IMAGE you can wire to anything that takes an image - a Save node, another composite, an upscale step.

Installing it

The Kaizen Package has no heavy dependencies - its requirements.txt is literally just torch>=2.0.0, which every ComfyUI install already has. No model downloads. Install via ComfyUI Manager by searching "Kaizen Package", or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/aleolidev/comfy_kaizen_package

Then restart ComfyUI and it appears under the kaizen/image category.

Common issues

  • Nothing appears at all. Check that the foreground's offset actually overlaps the background. Off-canvas positions don't error - they just return the background untouched.
  • You need a MASK, not an RGBA image. If your foreground came out of a matting model with baked-in alpha, extract that channel with "Image to Mask" first.
  • Fuzzy edges on a coarse mask. The auto-resize is bilinear, so a tiny hard-edged mask upscaled to a big foreground gets soft alpha. For crisp edges, match the mask size upstream instead of relying on the node to stretch it.
  • Only frame 0 of a batch is composited. Design around it - loop per-frame or batch before the composite.

Two honest caveats: the pack is young (v0.0.1), and the README's manual clone command points at aleolidev/kaizen_package which is a 404 - use the comfy_kaizen_package URL above. Also, the repo's shipped pytest tests/ suite still imports a placeholder Example node that doesn't exist, so the tests fail out of the box. None of that affects the node itself, which is GPLv3 and straightforward to read if you want to tweak it.

Categorykaizen/image

Inputs (5)

NameTypeDefaultDescription
backgroundIMAGEBackground image
foregroundIMAGEImage to overlay
maskMASKAlpha mask (1.0=opaque, 0.0=transparent)
xINT0-4096–4096Horizontal position (negative values supported)
yINT0-4096–4096Vertical position (negative values supported)

Outputs (1)

NameTypeDescription
compositeIMAGE