Image Blend Mask Center
Paste a source onto a mask's center, edge-clamped
- destination
- source
- mask
- IMAGE
Here's a node that does one narrow thing and does it cleanly: it takes a destination image, a source image, and a mask, and pastes the source onto the destination centered on the mask's bounding box. If the mask marks a face, the source lands on the face. If the mask is empty, the source lands dead-center. And if the source would stick out past the edges, it clamps so nothing hangs off the canvas.
It's a hard paste - no feathering, no blending, no alpha. The mask is used purely to find the target position. The mechanism: find every nonzero pixel in the mask, take the middle of its bounding box, compute where the source's center should go, and snap to the canvas edges if it would overflow. The source comments call the edge behavior "磁吸" - magnet-snapping - which is a fair description. It also aligns batch sizes by repeating the destination, source, and mask across whatever the largest count is.
So when do you want it? The classic use is putting a patch back into a region you know only by its mask - say, "the inpainting model made the face good, paste it back where the face was." The honest caveat: if you have bounds rather than a mask, the pack's more precise round-trip - Image Crop By Mask → Image Uncrop By Bound - is the better tool, because it remembers the exact crop rectangle and blends with feathering on the way back. Image Blend Mask Center is the simpler, center-based alternative when you don't care about pixel-perfect bounds, just "put it where the mask is."
Inputs and outputs that matter
- destination (in) - the image being pasted onto.
- source (in) - the image being pasted in.
- mask (in) - used to find the center; the paste position is the mask's bounding-box midpoint.
- IMAGE (out) - the destination with the source pasted in place.
Installing it
Part of wenchengxiang/ComfyUI-Practical-Tools. ComfyUI Manager → Custom Nodes Manager → search "ComfyUI-Practical-Tools" → Install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
then restart. No pip install, no requirements file, no models - pure Python on ComfyUI's bundled stack.
Issues and gotchas
Three things to keep straight. First, it's a hard overwrite - pixels under the paste are replaced outright, so a source with a busy background will look stamped unless you feather or mask it yourself. Second, if source is bigger than destination, it just centers and clips the overflow; that's by design, not an error. Third, a fully black mask means "no position found," and the node falls back to the destination's center - which is often not what you meant. In short: use it for quick mask-anchored paste jobs, and graduate to the crop/uncrop pair when seams start to matter.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| destination | IMAGE | — | |
| source | IMAGE | — | |
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |