GR Image Paste With Mask
GR Image Paste With Mask
- background_image
- overlay_image
- mask_image
- output_image
- inverted_mask_image
- contour_image
- image_dimensions
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, default100) - overall strength of the paste.overlay_x/overlay_y(INT, default0) andoverlay_fit(defaultcenter) - 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.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| background_image | IMAGE | — | |
| overlay_image | IMAGE | — | |
| mask_image | MASK | — | |
| opacity | FLOAT | 100.00–100 | — |
| overlay_x | INT | 0-250–250 | — |
| overlay_y | INT | 0-250–250 | — |
| overlay_fit | COMBO | center | 9 options: left, right, center, top, top left, top right, +3 |
| mask_x | INT | 0-250–250 | — |
| mask_y | INT | 0-250–250 | — |
| mask_fit | COMBO | center | 13 options: left, right, center, top, top left, top right, +7 |
| mask_zoom | INT | 0-250–250 | — |
| mask_stretch_x | INT | 0-250–250 | — |
| mask_stretch_y | INT | 0-250–250 | — |
| outline | BOOLEAN | false | — |
| outline_thickness | INT | 21–50 | — |
| outline_colour | COMBO | black | 30 options: amethyst, black, blue, cyan, diamond, emerald, +24 |
| outline_opacity | FLOAT | 100.00–100 | — |
| outline_position | COMBO | center | 3 options: center, inside, outside |
| blend | BOOLEAN | false | — |
| blend_method | COMBO | add | 14 options: add, subtract, multiply, screen, overlay, difference, +8 |
| blend_strength | FLOAT | 50.00–100 | — |
| blend_area | COMBO | all | 4 options: all, inside, outside, outline |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| output_image | IMAGE | — |
| inverted_mask_image | IMAGE | — |
| contour_image | IMAGE | — |
| image_dimensions | STRING | — |