Y7 Paste Cropped Image Back
Paste an edited crop back — without knowing your image dimensions
- image_orig
- image_crop
- IMAGE
- MASK
Crop-and-stitch editing is one of the most practical ComfyUI moves left in the masked-inpainting playbook: crop a region, run it through img2img or an inpaint pass at full resolution, then paste the result back so nothing else in the frame moves a pixel. Y7 Paste Cropped Image Back is the "paste back" half. It's a variant of the WAS node of the same name, with one meaningful change: right and bottom are measured inward from the edges, so you can target regions without knowing the image dimensions in advance.
It's from the Y7Nodes pack.
How the coordinates work
The paste region is defined by four edge offsets:
x1 = left- pixels from the left edgey1 = top- pixels from the top edgex2 = image_width - right- pixels inward from the right edgey2 = image_height - bottom- pixels inward from the bottom edge
That last bit is the differentiator. In the WAS original, right/bottom are absolute positions from the top-left, which forces you to know your image size. Here, set right=256, bottom=256 and you always target the bottom-right 256-wide strip, regardless of whether the image is 1024×1024 or 2048×1152. For edge-relative fixes - "bottom right corner of anything" - it's genuinely convenient.
The README also notes this pairs well with OLM Drag Crop, a custom node that lets you drag-select a crop and outputs the coordinates directly, which wire straight into left/top/right/bottom.
The inputs that matter
image_orig- the base image you're pasting onto.image_crop- the (edited) crop to paste. It gets resized to exactly fit the paste region - so if you upscaled the crop for img2img, it's scaled back down during pasting. There's no aspect-ratio preservation: if the crop's aspect ratio doesn't match the region, it's stretched, so keep the crop region roughly proportional to what you'll paste.left/top/right/bottom- the four offsets above.crop_blending- feathering at the paste edges (0.0–1.0, default 0.25). This is what hides the seam; start low and raise it if you see a hard boundary.crop_sharpening- 0–3 sharpening passes applied to the crop before pasting. Useful when the img2img pass softened the crop relative to the base.
Outputs are IMAGE (the composited result) and MASK (the blended mask used for the paste), the latter useful if you want to inspect or reuse the region boundary.
Where it fits
The KB's inpainting essay makes the case for masked work clearly: bit-identical unmasked pixels and full-resolution detail on just the edited region are the two things instruction-edit models still can't give you. This node is the compositing end of exactly that loop. The workflow: crop a face or a hand region → render it upscaled → paste back with feathering → done, and everything outside the region is untouched. The edge-relative coordinates make it robust to resolution changes across the batch - no per-image math.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/yushan777/ComfyUI-Y7Nodes
cd ComfyUI-Y7Nodes
pip install -r requirements.txt
Restart ComfyUI, or install via ComfyUI Manager → search "Y7Nodes".
Gotchas
The stretch behavior is the one to respect: a mismatched crop aspect ratio distorts rather than letterboxes, so match the crop's proportions to the paste region. Also, the offsets are pixels, and right/bottom being inward-from-the-edge means you can't express "all the way to the edge" with a zero - zero puts the boundary at the edge, which is the same thing, but worth knowing the semantics. For one-off jobs the WAS original is fine; for repeatable edge-relative edits, this variant is the better fit.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image_orig | IMAGE | Base image to paste onto | |
| image_crop | IMAGE | Image to paste into the defined region (will be resized to fit) | |
| left | INT | 00–10000000 | Pixels from the left edge to the left of the paste region |
| top | INT | 00–10000000 | Pixels from the top edge to the top of the paste region |
| right | INT | 00–10000000 | Pixels inward from the RIGHT edge to the right of the paste region |
| bottom | INT | 00–10000000 | Pixels inward from the BOTTOM edge to the bottom of the paste region |
| crop_blending | FLOAT | 0.250–1 | Blending/feathering amount at the edges of the pasted region |
| crop_sharpening | INT | 00–3 | Number of sharpening passes applied to the crop before pasting |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | IMAGE | — |