Nodes/ComfyUI-RefineNode/RefineNode Merge Generated Images
ComfyUI Node

RefineNode Merge Generated Images

Merge generated images the way Paste Back does, but without touching the original

By 1Kynx·Created 4 months ago·Updated 26 days ago· 30
RefineNode Merge Generated Images
  • generated_image
  • info
  • image
  • paste_mask
mask_sourcemask
mask_grow3
blend_blur5
show_full_imagefalse

RefineNode Paste Back restores generated results into the original image. RefineNode Merge Generated Images is the sibling that goes the other way: instead of pulling the model output back to the original's coordinates, it scales the original-image background up into generated-result coordinates and composites the generated pixels on top. Same masking, same seam-fixing, but the output lives in model space rather than source space.

Why would you want that? Two honest reasons. First, when you're refining the same region in a loop - refine, look, tweak the prompt, refine again - you don't want to keep round-tripping through the full-res original; a merged image at generation resolution is enough to judge and iterate. Second, when several regions of one product were generated at the same scale, merging in that space gives you one clean patch sheet you can save or feed onward without upscaling the source first. If all you want is a finished product shot, use Paste Back. If you're mid-pipeline, this is the one.

Inputs and outputs

  • generated_image - the model's output(s). The count must match the number of info items, or the node errors.
  • info - the same REFINENODE_INFO chain Paste Back uses. This node reads the Reference Image Process geometry to place each patch.
  • mask_source (default mask) - composite using the mapped mask shape or its bounding box. Older workflows that still wire an input named paste_back_mode are accepted as a compatibility fallback.
  • mask_grow (default 3) and blend_blur (default 5) - the same edge/feather controls as Paste Back. In this node the paste masks are grown and feathered in model space before being mapped to generated-patch space, which the README notes matches Paste Back's compositing order more closely.
  • show_full_image (default off) - off returns the final paste-mask crop; on returns the full scaled source-image canvas.

Outputs: image (the merged result, in scaled generated-result coordinates) and paste_mask (the combined mask for the generated regions in the returned image size).

How the geometry works

Because patches can land at different scales, the node computes a per-group scale. When all entries in one source group match, no resampling happens - patches are placed as-is. When scales differ, it picks the group's median scale and resamples only the entries that need it so everything can share one output canvas. In disable crop mode (from Reference Image Process) there's no clean single scale, so it approximates and may resample a patch if x/y scaling differs.

Placement follows the crop mode you chose upstream: crop mode offsets by the model's source_content_box, while fill mode composites only the generated target_content_box content and ignores padding - which is why fill can yield unexpected letterboxing if you're not expecting padding to be dropped.

Install and run

The usual - ComfyUI Manager, search "ComfyUI-RefineNode", or:

cd ComfyUI/custom_nodes
git clone https://github.com/1Kynx/ComfyUI-RefineNode.git

Restart ComfyUI. No extra dependencies. The node is pure compositing, so it runs without the Qwen/RefineAnything model stack; you only need that stack for the generation that feeds it.

Gotchas

  • Count mismatch errors are the most common failure - every info item needs its own generated image. Check your batch before blaming the merge.
  • Unexpected padding in the output - you're on fill crop mode and the padding is being ignored by design. If the letterbox bugs you, switch the upstream Reference Image Process to crop mode.
  • If the merged result looks misaligned, verify the info chain from Preprocess Mask through Reference Image Process is unbroken - the geometry this node trusts lives there.
CategoryRefineNode

Inputs (6)

NameTypeDefaultDescription
generated_imageIMAGE
infoREFINENODE_INFO
mask_sourceCOMBOmask2 options: mask, bbox
mask_growINT30–256
blend_blurINT50–256
show_full_imageBOOLEANfalse

Outputs (2)

NameTypeDescription
imageIMAGE
paste_maskMASK