Paste By Mask Gr85
Compositing a processed patch back into the full image
- image_base
- image_to_paste
- mask
- mask_mapping_optional
- IMAGE
This is the paste-back half of the detect → crop → resample → paste pattern that a huge share of ComfyUI's detail-improvement tooling runs on - Impact Pack's Detailer being the most familiar example. You've cropped a region out, run a fresh sampling pass on it at proper resolution, and now you need it back in the original image, in the right place, at the right size, blended cleanly through a mask. That's the entire job here.
The "Gr85" suffix on the class name is a strong tell about where this node came from: resize_behavior's six options - resize, keep_ratio_fill, keep_ratio_fit, source_size, source_size_unmasked, keep_ratio_unmasked - line up closely with the long-standing "Paste By Mask" node from the Masquerade Nodes / Impact Pack corner of the ecosystem. Reads like the author kept the behavior but renamed the class to avoid a node-ID collision with the original if you happen to have both packs installed - which, if you're running comfyui_gr85's Mask Batch to SEGS alongside actual Impact Pack, you very well might.
Inputs and what they actually mean. image_base is the full image you're pasting into; image_to_paste is the patch - typically a Detailer's refined crop, or anything else you've processed separately. mask defines where the paste lands - and here's a real gotcha worth flagging up front: this node's schema types mask as IMAGE, not MASK. If you're wiring straight from a MASK-typed output elsewhere in your graph, you may need a "Convert Mask to Image" node in between before ComfyUI will let you connect it. resize_behavior controls how image_to_paste gets scaled to fit the masked region: resize stretches to fill regardless of aspect ratio; keep_ratio_fill/keep_ratio_fit preserve aspect ratio while covering or fitting the region respectively; source_size and source_size_unmasked paste at native resolution (cropped to the mask, or not); keep_ratio_unmasked is the aspect-ratio-preserving version of an unmasked paste. There's also an optional mask_mapping_optional (type MASK_MAPPING) - a coordinate-mapping object, presumably handed off by whatever node cropped image_to_paste in the first place, so the paste lands exactly where the crop came from even after resizing. Output is a single IMAGE.
Installing it. Standard: search "comfyui_gr85" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/veighnsche/comfyui_gr85
Restart ComfyUI. No model weights involved - this is compositing math.
Where it goes wrong. The IMAGE-typed mask input is the one that trips people up first - if ComfyUI refuses the connection from a MASK output, that's why, not a bug. Second: leaving mask_mapping_optional unset is fine for a simple same-position paste, but if image_to_paste came from a crop-and-resize step upstream and the composite lands visibly offset, that missing mapping is almost certainly the reason.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_base | IMAGE | — | |
| image_to_paste | IMAGE | — | |
| mask | IMAGE | — | |
| resize_behavior | COMBO | 6 options: resize, keep_ratio_fill, keep_ratio_fit, source_size, source_size_unmasked, keep_ratio_unmasked | |
| mask_mapping_optionalopt | MASK_MAPPING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |