Paste with Masks
Paste with Masks
- image_source
- mask_source
- image_dest
- mask_dest
- image_out
paste is the back half of the crop-refine-paste loop. You took a region out of an image, did something to it - upscaled it, refined it, swapped it - and now you need to put it back where it came from, blended cleanly. This node does that using masks on both ends: a mask on the source that acts as its alpha (what to keep), and a mask on the destination that marks where it goes.
Why you'd reach for it
Once you've cropped out a face or an object and resampled it at full resolution, dropping it back in is deceptively annoying. The refined region is a different size than the hole it came from, its edges are hard, and you need it to land in exactly the right place. paste handles the crop-and-resize-to-fit and treats the source mask as an alpha channel, so the pasted region feathers into the destination instead of sitting on top like a sticker. This is the same detect-crop-resample-composite pattern that makes detailing workflows work; paste is the composite step done as a reusable primitive.
If you don't need scaling and just want to drop one image onto another at an offset, the sibling Alpha Composite node is simpler. Reach for paste when the source and destination regions are different sizes and you want the node to reconcile them.
How it works
It treats mask_source as the source image's alpha - white pixels are kept, black are transparent. It then pastes the (alpha-cut) source onto image_dest, using mask_dest as the target area to paste into, cropping and resizing the source as needed so it fits that area. The output image and mask are padded by the horizontal and vertical padding values, with a global option to pad both at once.
The inputs that matter
- image_source / mask_source - the region you're pasting in, and the mask that becomes its alpha. Anything black in
mask_sourcewon't be pasted. - image_dest / mask_dest - the image you're pasting onto, and the mask marking where the source should land. The destination mask is what tells the node the target area to fit into.
- scale_mode (optional) - interpolation used when resizing the source to fit:
nearest,nearest-exact,bilinear(default),bicubic. Bilinear is the safe default.
The output is a single image_out: the destination with the source composited in.
Installing it
ComfyUI Manager → search antrobots ComfyUI Nodepack. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/antrobot1234/antrobots-comfyUI-nodepack
Restart ComfyUI. It's a pure image/mask operation - nothing to download.
Common issues
The most common confusion is which mask does what. mask_source is the alpha of the thing you're pasting (keep the white, drop the black). mask_dest is the location - the area of the destination the source gets fitted into. Swap them by accident and you'll get the source pasted into the wrong region, or cut to the wrong shape.
Second, hard edges. If the seam shows, the usual culprit is a razor-sharp source mask. A slightly soft/feathered mask_source gives the alpha blend something to work with, and pairing this with a crop that had a bit of padding (so the region carries some surrounding context) makes the paste far less obvious.
This is a niche node in a small single-author pack - there's essentially no community troubleshooting thread to lean on, so if something's genuinely broken, a GitHub issue on the pack is the move.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_source | IMAGE | — | |
| mask_source | MASK | — | |
| image_dest | IMAGE | — | |
| mask_dest | MASK | — | |
| scale_modeopt | COMBO | bilinear | 4 options: nearest, nearest-exact, bilinear, bicubic |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image_out | IMAGE | — |