Nodes/ComfyUI-Apt_Preset/create_mask_array
ComfyUI Node

create_mask_array

Splitting a canvas into a grid of masks by ratio

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
create_mask_array
    • 合成图片
    • 遮罩阵列
    width512
    height512
    split_mode
    split_pattern1-1

    If you need a grid of masks - evenly or unevenly split columns or rows, ready to composite different content into each cell - hand-drawing each rectangle gets old fast. create_mask_array generates the whole set from a canvas size and a ratio pattern.

    What it is and why you'd reach for it

    This is one of ComfyUI-Apt_Preset's mask utilities, and it's genuinely handy for panel layouts, side-by-side comparison grids, or batch-region masking where you want several evenly-spaced (or ratio-weighted) regions defined at once rather than building them one Coordinate_create_mask at a time. One thing worth flagging up front: it's filed under the pack's "🚫backup" category, which is the author's own marker for a node kept around for compatibility rather than the actively-showcased path - it should still work, just don't expect it to get README changelog attention going forward.

    Another thing worth flagging honestly: this node's own dropdown and outputs are labeled in Chinese in the ComfyUI graph, since that's literally what the pack author wrote into the schema. split_mode's two options translate to "split by width" and "split by height," and the two outputs translate to "composite image" and "mask array" respectively. Knowing that up front saves you from hunting through menus trying to guess which option does what.

    How it works

    Set width/height for the canvas, pick split_mode (split along width vs. height), and describe the split with split_pattern - a string like the default "1-1", which reads as a ratio pattern: two equal segments. The pattern format supports more than just even splits (the field is a free-text STRING, not a fixed enum), so you can presumably weight segments unevenly with a pattern like "1-2" for a narrow-then-wide split - test with a simple pattern first to confirm the exact syntax the node expects before building something complex.

    Inputs and outputs that matter

    • width / height (16–99999, step 16, default 512) - canvas dimensions.
    • split_mode (enum, 2 options) - split along width or along height.
    • split_pattern (STRING, default "1-1") - the ratio pattern describing how many segments and their relative sizes.

    Outputs: a composite reference image (all cells shown together) and a mask array - a list of MASK, one per grid cell (is_list: true), ready to wire into a batch-compositing step where each cell gets different content.

    Installing it

    Through ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
    

    Run install.bat on Windows for dependencies; on Linux/Mac install the requirements by hand. No model downloads needed - this is grid math, nothing to fetch.

    Common issues

    If split_pattern doesn't do what you expect, start from the working "1-1" default and change one number at a time rather than guessing a complex pattern outright - the schema doesn't spell out the exact grammar beyond the example, and confirming the syntax empirically is faster than reverse-engineering it from the source.

    Since this node is in the pack's "backup" category, treat it as functional-but-not-current - worth a quick test after any Apt_Preset update in case behavior shifts. And as with the rest of this pack: it's large and actively developed, and at least one user has reported an IMPORT FAILED error at ComfyUI startup after installing it. Check the console log if this node doesn't appear.

    CategoryApt_Preset/mask/😺backup

    Inputs (4)

    NameTypeDefaultDescription
    widthINT51216–99999
    heightINT51216–99999
    split_modeCOMBO2 options: 按宽分割, 按高分割
    split_patternSTRING1-1

    Outputs (2)

    NameTypeDescription
    合成图片IMAGE
    遮罩阵列MASK