Nodes/Y7Nodes for ComfyUI/Y7 Paste Cropped Image Back
ComfyUI Node

Y7 Paste Cropped Image Back

Paste an edited crop back — without knowing your image dimensions

By yushan777·Created about a year ago·Updated 4 days ago· 8
Y7 Paste Cropped Image Back
  • image_orig
  • image_crop
  • IMAGE
  • MASK
left0
top0
right0
bottom0
crop_blending0.25
crop_sharpening0

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 edge
  • y1 = top - pixels from the top edge
  • x2 = image_width - right - pixels inward from the right edge
  • y2 = 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.

CategoryY7Nodes/Image

Inputs (8)

NameTypeDefaultDescription
image_origIMAGEBase image to paste onto
image_cropIMAGEImage to paste into the defined region (will be resized to fit)
leftINT00–10000000Pixels from the left edge to the left of the paste region
topINT00–10000000Pixels from the top edge to the top of the paste region
rightINT00–10000000Pixels inward from the RIGHT edge to the right of the paste region
bottomINT00–10000000Pixels inward from the BOTTOM edge to the bottom of the paste region
crop_blendingFLOAT0.250–1Blending/feathering amount at the edges of the pasted region
crop_sharpeningINT00–3Number of sharpening passes applied to the crop before pasting

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKIMAGE