Advanced Composite Image Masked
Paste one image onto another, anchored and masked
- base_image
- overlay_image
- mask
- IMAGE
You've cut a subject out of one image and you want to drop it onto another - a new background, a bigger canvas, a scene you're assembling piece by piece. The fiddly part is never the cutting, it's the placing: figuring out pixel offsets by hand every time you resize the base image gets old fast. Advanced Composite Image Masked handles the placement math for you, using named anchor points instead of raw coordinates you have to recompute every time something changes size.
This is the node you reach for right after a background-removal step (rembg, BiRefNet, whatever produced your cutout) - it's the "now put it somewhere" half of that workflow, not the "cut it out" half.
How it works
You give it a base_image to paste onto, an overlay_image to paste, and a mask that controls how the paste blends - feed it the overlay's own alpha/silhouette mask for a clean cutout paste, or a solid white mask if you just want a hard rectangular overwrite with no soft edges. Positioning happens in two stages: anchor picks one of nine reference points on the base canvas - the familiar 3×3 grid (top-left through bottom-right, plus the three centers), the same convention most design tools use for object placement - and x_position/y_position place the overlay relative to that anchor. x_offset/y_offset then nudge it further without disturbing the anchor logic. Anchoring first and fine-tuning second means you can reposition after resizing the base canvas without redoing pixel math from scratch.
The inputs and outputs that matter
- base_image, overlay_image - the canvas and the thing being pasted onto it.
- mask - controls blending at the paste boundary; this is what keeps edges from looking like a sticker slapped on top.
- anchor - one of nine named positions (
top-left,top-center,top-right,center-left,center,center-right,bottom-left,bottom-center,bottom-right). - x_position / y_position and x_offset / y_offset - coarse placement relative to the anchor, then fine nudging.
- Output: a single composited IMAGE.
How to install it
Part of the same six-node ComfyUI UX Nodes pack, from Reddit user Anibaaal - who's more recognizable on r/StableDiffusion for a widely-shared Flux LoRA than for custom nodes, which fits: this reads like a working photographer/hobbyist's personal utility drawer, not a maintained product. The README is a bare node list with no install or dependency notes, so use the standard path:
Through ComfyUI Manager: search ComfyUI UX Nodes, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Anibaaal/ComfyUI-UX-Nodes
then restart. Pure image compositing, no models, no unusual dependencies.
Common issues & troubleshooting
Tensor shape mismatch errors. This is the single most common ComfyUI footgun in general, and it applies directly here: mask needs to match overlay_image's dimensions, not the base's. If your mask came from a different step than the one that produced the overlay - say, a background-removal mask applied to a since-cropped copy of the image - the sizes drift apart and the node errors out rather than silently coping.
Placement feels harder to reason about than it should. Start from anchor: center with both offsets at 0, confirm the paste lands where you expect, then adjust from there - it's much easier to nudge from a known-good center point than to compute absolute coordinates from top-left in your head.
Hard edges you didn't want. If the paste looks obviously pasted-on, check what's actually feeding the mask input - a fully opaque rectangular mask gives you a hard-edged overwrite every time, regardless of how clean your cutout was upstream.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| base_image | IMAGE | — | |
| overlay_image | IMAGE | — | |
| mask | MASK | — | |
| x_position | INT | 0 | — |
| y_position | INT | 0 | — |
| anchor | COMBO | top-left | 9 options: top-left, top-center, top-right, center-left, center, center-right, +3 |
| x_offset | INT | 0 | — |
| y_offset | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |