NGs Multimask - Write
Packing several masks into one image's bit planes
- image
- mask
- Multimask Image
If you've ever needed more than one or two masks alive in the same workflow - region A gets one LoRA, region B gets another, region C stays untouched - you already know how fast plain MASK sockets multiply and how hard they get to track. Multimask Write is this pack's answer: instead of juggling separate mask objects or images, it stores several independent on/off masks inside the bit planes of one image, using individual bits of the red, green, and blue channels as separate slots. Eight bits per channel across three channels is room for up to 24 masks packed into a single picture.
How it works
You write one mask per call. channel picks which color channel (red, green, or blue) this call writes into, and level picks which bit within that channel - the choices (1, 2, 4, 8… up to 128) are powers of two, i.e. individual bit positions, not arbitrary numbers. The optional image input is the canvas to accumulate into: leave it empty on your first Write call and it starts from a blank width × height canvas; feed it the previous call's output to keep stacking more masks into the same image. The optional mask input is the actual on/off data being written into that slot.
The inputs and outputs that matter
width,height- canvas size, stepping in multiples of 8.channel- red / green / blue, which color channel this mask lives in.level- which bit (1 through 128) within that channel.image(optional) - the canvas to write into; omit to start fresh.mask(optional) - the mask data for this particular call.
Output is "Multimask Image" - feed it into another Write call to add more masks, or into NGs Multimask Read to pull one back out.
How to install it
ComfyUI Manager: search "NeoGriever," install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/NeoGriever/ComfyUI-NeoGriever
then restart. No dependencies to worry about.
Common issues & troubleshooting
Write and Read disagree on channel/level. There's no metadata stored anywhere describing what's packed where - the channel + bit position is the entire address for a given mask. Keep a note (even just in your node titles) of which channel and level you used for each mask, or Read will pull back the wrong slot, or noise.
Mismatched dimensions across a Write chain. Every Write call in a chain should use the same width/height, since each one is modifying the same underlying canvas. A size mismatch partway through will misalign or clip whichever mask gets written at the wrong resolution.
Expecting this to work outside the pack. This is a from-scratch bit-packing scheme specific to NeoGriever's own Write/Read pair - it won't round-trip through any other tool. Open a Multimask Image in a normal editor and you'll just see a slightly noisy-looking picture, not something self-describing.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 5128–16384 | — |
| height | INT | 5128–16384 | — |
| channel | COMBO | red | 3 options: red, green, blue |
| level | COMBO | 1 | 8 options: 1, 2, 4, 8, 16, 32, +2 |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Multimask Image | IMAGE | — |