RefineNode Merge Generated Images
Merge generated images the way Paste Back does, but without touching the original
- generated_image
- info
- image
- paste_mask
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 ofinfoitems, or the node errors.info- the sameREFINENODE_INFOchain Paste Back uses. This node reads theReference Image Processgeometry to place each patch.mask_source(defaultmask) - composite using the mapped mask shape or its bounding box. Older workflows that still wire an input namedpaste_back_modeare accepted as a compatibility fallback.mask_grow(default 3) andblend_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
infoitem needs its own generated image. Check your batch before blaming the merge. - Unexpected padding in the output - you're on
fillcrop mode and the padding is being ignored by design. If the letterbox bugs you, switch the upstreamReference Image Processtocropmode. - If the merged result looks misaligned, verify the
infochain fromPreprocess MaskthroughReference Image Processis unbroken - the geometry this node trusts lives there.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| generated_image | IMAGE | — | |
| info | REFINENODE_INFO | — | |
| mask_source | COMBO | mask | 2 options: mask, bbox |
| mask_grow | INT | 30–256 | — |
| blend_blur | INT | 50–256 | — |
| show_full_image | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| paste_mask | MASK | — |