Nodes/GraftingRayman/GR Image Paste With Mask
ComfyUI Node

GR Image Paste With Mask

GR Image Paste With Mask

By GraftingRayman·Created 2 years ago·Updated about a month ago· 76
GR Image Paste With Mask
  • background_image
  • overlay_image
  • mask_image
  • output_image
  • inverted_mask_image
  • contour_image
  • image_dimensions
opacity100.0
overlay_x0
overlay_y0
overlay_fitcenter
mask_x0
mask_y0
mask_fitcenter
mask_zoom0
mask_stretch_x0
mask_stretch_y0
outlinefalse
outline_thickness2
outline_colourblack
outline_opacity100.0
outline_positioncenter
blendfalse
blend_methodadd
blend_strength50.0
blend_areaall

This is the compositing workhorse of the whole pack - the node you reach for when plain GR Image Paste's "opacity over the whole frame" isn't enough and you actually need to place something, mask it, blend it, and put a border around it. It's a lot of node for a lot of reasons: sticker/logo placement with a soft edge, character cutouts pasted onto a new background, product shots composited with a drop shadow-style outline, that kind of thing.

How it works

At the core it's three images doing three jobs: background_image is your base canvas, overlay_image is what gets pasted on top, and mask_image controls which parts of the overlay are actually visible - everything else about the node is controls for how that paste happens.

Position and sizing are split into two independent systems: overlay_x/overlay_y plus overlay_fit (nine anchor presets - corners, edges, and center) place the overlay image itself, while mask_x/mask_y, mask_fit (a longer list of thirteen, including zoom_left/zoom_center/zoom_right variants), mask_zoom, and mask_stretch_x/mask_stretch_y independently reposition, scale, and stretch the mask relative to the overlay. That split matters - you can keep your overlay pinned in place while nudging or zooming just the mask to fine-tune the cutout edge, which is exactly the kind of adjustment that's fiddly to do by hand with separate crop/resize nodes.

On top of the paste, there's an optional outline (outline, outline_thickness, a 30-color outline_colour palette, outline_opacity, and outline_position for whether it sits centered on the edge, fully inside, or fully outside it) - good for making a pasted element read clearly against a busy background. And there's an optional blend pass (blend, blend_method with 14 modes including multiply, screen, overlay, difference, hard_light, and soft_light, plus blend_strength and blend_area to restrict the blend to just the inside, outside, or outline region) if you want the overlay to interact with the background's colors rather than sit flatly on top of it.

The inputs and outputs that matter

Don't feel obligated to touch everything above on your first pass - most jobs only need:

  • background_image, overlay_image, mask_image - the three required images.
  • opacity (FLOAT, default 100) - overall strength of the paste.
  • overlay_x / overlay_y (INT, default 0) and overlay_fit (default center) - where the overlay lands.

Everything else - outline, blend, mask repositioning - is there for when the default paste isn't polished enough, not something you need on every use.

Four outputs come back: output_image (the finished composite - what you'll wire onward most of the time), inverted_mask_image, contour_image (a preview of the mask's detected edge, useful for checking your outline settings actually line up with the cutout), and image_dimensions (STRING, the resulting size as text - handy for feeding a details-saver or debug text node downstream).

How to install it

Via ComfyUI Manager: search "GraftingRayman", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/GraftingRayman/ComfyUI_GraftingRayman

then restart. Every node in this pack shares one hard dependency - OpenAI's CLIP package, on top of whatever CLIP ComfyUI already has:

# portable build
.\python_embeded\python.exe -m pip install git+https://github.com/openai/CLIP.git

# system python
pip install git+https://github.com/openai/CLIP.git

Miss that step and the pack fails to import as a whole, this node included.

Common issues & troubleshooting

Nodes missing from search entirely - that's the CLIP dependency above, not this node specifically.

The overlay lands in the wrong spot. Remember overlay_fit/overlay_x/overlay_y and mask_fit/mask_x/mask_y are two separate coordinate systems. It's easy to nudge the mask thinking you're moving the overlay, or vice versa - if your paste looks offset from your mask's edge, check you adjusted the right pair.

Outline doesn't show up. outline defaults to off - you have to explicitly enable it before outline_thickness/outline_colour/outline_position do anything.

Composite looks flat or too "pasted on." That's what the blend controls are for. Try multiply or soft_light at a modest blend_strength (20–40) restricted to blend_area: inside before reaching for anything more aggressive - it goes a long way toward making an overlay feel like it belongs in the scene rather than sitting on top of it.

CategoryGraftingRayman/Images

Inputs (22)

NameTypeDefaultDescription
background_imageIMAGE
overlay_imageIMAGE
mask_imageMASK
opacityFLOAT100.00–100
overlay_xINT0-250–250
overlay_yINT0-250–250
overlay_fitCOMBOcenter9 options: left, right, center, top, top left, top right, +3
mask_xINT0-250–250
mask_yINT0-250–250
mask_fitCOMBOcenter13 options: left, right, center, top, top left, top right, +7
mask_zoomINT0-250–250
mask_stretch_xINT0-250–250
mask_stretch_yINT0-250–250
outlineBOOLEANfalse
outline_thicknessINT21–50
outline_colourCOMBOblack30 options: amethyst, black, blue, cyan, diamond, emerald, +24
outline_opacityFLOAT100.00–100
outline_positionCOMBOcenter3 options: center, inside, outside
blendBOOLEANfalse
blend_methodCOMBOadd14 options: add, subtract, multiply, screen, overlay, difference, +8
blend_strengthFLOAT50.00–100
blend_areaCOMBOall4 options: all, inside, outside, outline

Outputs (4)

NameTypeDescription
output_imageIMAGE
inverted_mask_imageIMAGE
contour_imageIMAGE
image_dimensionsSTRING