D2 Image Mask Stack
Batch your images and their masks in one node
- IMAGE
- MASK
D2 Image Mask Stack is the batch-your-pairs node: it takes multiple image/mask pairs and merges the images into one IMAGE batch and the masks into one MASK batch, keeping the two aligned so downstream nodes can process a whole set of inpaint regions, face fixes, or cut-and-paste jobs at once.
It's essentially D2 Image Stack with mask support bolted on - the author is upfront that the two are siblings. Where it earns its keep is any workflow that has to touch a handful of masked regions in one pass: composite a set of inpaint areas, run a batch of cut-by-mask operations, or feed several image+mask combos into a single KSampler run. Without it you're juggling two batch nodes and praying the ordering matches.
The inputs
image_count- how many pairs you want, 1 to 50. Set it to 3 and you getimage_1/mask_1throughimage_3/mask_3input sockets.
That's the only fixed input; the pairs are the real inputs, added dynamically by the frontend.
Outputs
IMAGE- all the connected images concatenated into one batch.MASK- all the corresponding masks concatenated into one batch.
The node is tolerant about channel counts: if some images are RGB and others RGBA, it normalizes them to a common channel count (up-converting RGB to RGBA or dropping alpha) so the batch doesn't fail. Same behavior lives in D2 Image Stack.
Installing it
Part of the D2 pack. ComfyUI Manager → search "D2-nodes-ComfyUI" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/da2el-ai/D2-nodes-ComfyUI
Restart ComfyUI. No models, no heavy deps - piexif and charset-normalizer are the full list. Since v32.0.0 the pack targets ComfyUI's V3 schema; older ComfyUI builds should pin the pack before 32.0.0.
The catch
The ordering is your responsibility. Masks are batched in the order their input slots appear, and the node only includes a pair when both its image and mask are connected - if you wire image_1 to image_3's slot, that's where it lands. For a few pairs it's obvious; for a 20-pair stack, double-check that slot numbering matches what you think it does. Also, all masks should share the same spatial dimensions as their images or downstream ops will complain, though resizing a mask to match its image is a one-node fix away.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image_count | INT | 31–50 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |