Replace Part Of Image
Paste a patch onto an image without touching a single other pixel
- image_ref
- image_target
- mask
- image
This node is exactly what its name says and nothing else: it takes one image, drops it onto another at a coordinate you choose, and hands back the result. Think of it as ComfyUI's version of pasting in Photoshop. The entire pack is this single node - there's no model to download, no API, no key, and honestly no real reputation behind it (zero community discussion, zero search impressions). It's a five-line utility that some workflow somewhere needed, so its author shipped it.
Why would you reach for it? The crop-and-stitch inpainting trick, mostly. The classic way to fix a small detail - an eye, a logo, a watermark - is to crop that region, regenerate it at the model's native resolution, and paste it back. That's what masked inpainting uniquely gives you: bit-identical pixels everywhere you didn't ask to change. This node is the "paste it back" half of that pipeline, which is a step core ComfyUI annoyingly doesn't have as a bare primitive. Core's ImageCompositeMasked does the same job but resizes your source by default to fit the mask, which is often not what you want; this one never resizes, which makes it more predictable.
Mechanically it's trivial, and that's a good thing. Both inputs are just tensors (image_ref is the thing you're pasting, image_target is the canvas), no torch extras beyond what ComfyUI already ships. The ref lands with its top-left corner at left_top_x/left_top_y (both default 0), cropped at the target's edges if it overhangs - there's no auto-scale, so size your ref first with an ImageScale node. The optional mask blends the ref over the target within the pasted region only; where the mask is 0 you keep the original pixels, where it's 1 you get the ref. One gotcha: the mask is thresholded hard at 0.5, so a feathered mask collapses to a hard edge. No mask at all means a pure overwrite. Output is a single image tensor the same size as the target, clamped to a valid 0–1 range, so it feeds straight into a VAE Decode or a Save Image.
Install is painless:
cd ComfyUI/custom_nodes
git clone https://github.com/LoveEatCandy/COMFYUI-ReplacePartOfImage
Restart ComfyUI and it appears under its own "ReplacePartOfImage" category. Or just search "ReplacePartOfImage" in ComfyUI Manager. No requirements install, no model files - the only dependency is torch, which you already have.
Where people get burned: feeding a ref that's bigger than the target (it just silently crops), expecting a soft mask blend that the 0.5 threshold destroys, and batch mismatches. If you feed a batch of target images, the ref and mask can be a single frame or a same-sized batch - anything else throws an explicit error telling you exactly that. If you're already running a big node suite, you've probably got an equivalent buried somewhere. But when you just need a dead-simple paste that leaves the rest of the frame untouched, this does it in one node with zero surprises.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_ref | IMAGE | — | |
| image_target | IMAGE | — | |
| maskopt | MASK | — | |
| left_top_xopt | INT | 0 | — |
| left_top_yopt | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |