Nodes/comfyui_gr85/Paste By Mask Gr85
ComfyUI Node

Paste By Mask Gr85

Compositing a processed patch back into the full image

By veighnsche·Created 2 years ago·Updated 8 months ago· 1
Paste By Mask Gr85
  • image_base
  • image_to_paste
  • mask
  • mask_mapping_optional
  • IMAGE
resize_behavior

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.

CategoryGR85/Mask

Inputs (5)

NameTypeDefaultDescription
image_baseIMAGE
image_to_pasteIMAGE
maskIMAGE
resize_behaviorCOMBO6 options: resize, keep_ratio_fill, keep_ratio_fit, source_size, source_size_unmasked, keep_ratio_unmasked
mask_mapping_optionaloptMASK_MAPPING

Outputs (1)

NameTypeDescription
IMAGEIMAGE