Nodes/D2 Nodes ComfyUI/D2 Image Mask Stack
ComfyUI Node

D2 Image Mask Stack

Batch your images and their masks in one node

By da2el-ai·Created 2 years ago·Updated 5 days ago· 66
D2 Image Mask Stack
    • IMAGE
    • MASK
    image_count3

    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 get image_1/mask_1 through image_3/mask_3 input 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.

    CategoryD2/Image

    Inputs (1)

    NameTypeDefaultDescription
    image_countINT31–50

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK