Nodes/KMCDev Nodes/Image Blend Mask
ComfyUI Node

Image Blend Mask

Blend two images by a mask with a strength dial — once you remember the mask is inverted

By kevinmcmahondev·Created 2 years ago·Updated 2 years ago· 0
Image Blend Mask
  • image_a
  • image_b
  • mask
  • IMAGE
blend_percentage0.50

This is the node for the classic "put the inpainted result back onto the original" move: two images, one mask, one strength dial. Image Blend Mask takes image_a, image_b, a mask, and a blend_percentage (0–1, default 0.5), and gives you a single IMAGE out.

How it works. Both images get converted to Pillow, the mask is converted to grayscale and then - here's the thing - inverted internally. The first pass composites the two images by that inverted mask: where your original mask is white, you see image_b; where it's black, you keep image_a. Then a second pass blends the whole result against image_a, weighted by blend_percentage: 0 leaves image_a untouched, 1 applies the full masked swap, and the 0.5 default sits exactly halfway.

So the mental model is two knobs: your mask says where image_b shows through, and blend_percentage says how strongly to apply that. White mask → image_b. Crank the percentage to 1.0 to make it stick. The inversion is the part people trip on - especially since this pack's other mask node, ImageMixColorByMask, does not invert. Same author, opposite conventions; check which one you grabbed before you wonder why the blend is on the wrong side.

The socket gotcha that will bite you. The mask input here is an IMAGE type, not a MASK. A MASK tensor from SAM or the mask editor will refuse to plug in. Convert it first with ComfyUI's built-in Mask → Image node. And because the node converts the mask to grayscale internally, you can feed it a color image as a mask - its brightness drives the blend - but then you're at the mercy of whatever luma mapping your color produces, so a proper grayscale mask is the reliable path.

Where you'd reach for it: the inpaint round-trip (original as image_a, inpainted fill as image_b, mask over the repaired region); compositing a character render onto a background; or a crossfade between two images using a gradient mask when you want a manual transition instead of a lerp node. The strength dial makes it forgiving - you can dial a swap back to 60% to keep a hint of the original through it.

Install is the same for the whole pack: ComfyUI Manager → search "KMCDev" → Install, then restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/kevinmcmahondev/comfyui-kmcdev-image-filter-adjustments

then restart ComfyUI. No models or heavy deps - just numpy, Pillow and torch, which ComfyUI already ships with.

Troubleshooting. Blend appearing on the wrong region = inverted mask (flip it, or just remember white means image_b). A MASK socket won't connect = convert to IMAGE first. And the big one: image_a and image_b must be the same dimensions. The mask gets resized to match image_a, but Pillow's composite requires both source images to be the same size, so feeding mismatched sizes will error out - resize image_b to image_a before blending.

CategoryKMC DEV/Image

Inputs (4)

NameTypeDefaultDescription
image_aIMAGE
image_bIMAGE
maskIMAGE
blend_percentageFLOAT0.500–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE