Lazy Mix Images | akatz-loops
Mask-based image blending that skips the work it doesn't need
- image1
- image2
- mask
- IMAGE
LazyMixImages | akatz-loops blends two images by a mask, but it's built for the lazy-execution world, and that changes how you should think about it. It takes image1, image2, and a mask, and does the classic image1 * (1 - mask) + image2 * mask composite. What makes it interesting: it inspects the mask first, and if the mask is all zeros it never evaluates the image2 branch at all - and vice versa. The image that's fully masked out isn't just ignored, it's not even computed.
Inputs and outputs
- image1 (IMAGE) and image2 (IMAGE) - both lazy inputs.
- mask (MASK) - the blend weights, 0 = all image1, 1 = all image2, in-between = the weighted mix.
- output - a single IMAGE.
Two nice touches in the implementation: it handles 2D masks (adds the batch/channel dims it needs), and it broadcasts a single-channel mask up to match the image's channels. So you can feed a plain black-and-white mask from a mask-utility pack and it just works.
When you'd use it
The lazy angle shines inside a loop. Say each iteration either needs a clean pass-through or a mix with a freshly generated frame, decided by a mask that's sometimes fully black. A normal blend node would force both upstream image branches to render every iteration. This one only renders what the mask actually needs - which, over a 30-iteration loop, is a real time save.
It's also simply a clean composite node for "switch by mask" UI work - an inpainting result over the original, a region overlay - when you want the readability of one node instead of a Composite plus a Blend tangle.
Installing it
Part of the Akatz-Loop-Nodes pack (repo ComfyUI-Execution-Inversion):
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Execution-Inversion
# restart ComfyUI
Or ComfyUI Manager → "Akatz-Loop-Nodes". Only dependency is opencv-python; no model files.
Gotchas
The author's own comment flags it: it does not handle different batch sizes between the two images. If image1 is a batch of 4 and image2 is a single frame, you'll get a shape mismatch, not a broadcast. Keep both images (or both masks) at the same batch size. Also, the mask check looks at the whole mask's min/max - a mask with a single stray 1.0 pixel means image2 will be evaluated, so the lazy shortcut only pays off for genuinely solid masks. Not a bug, just set expectations.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | — | |
| image2 | IMAGE | — | |
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |