PettyPaintImagesToMasks
Extract a channel from every image in a batch and get a mask
- images
- MASK
Sometimes the selection you need is just sitting in a color channel of an image you already have - an RGBA layer's alpha, or a black-and-white matte painted into the red channel. PettyPaintImagesToMasks is the batch version of "pull that channel out and hand it to me as a MASK": same idea as the pack's PettyPaintImageToMask, but it processes every image in a batch so one call turns a whole stack of layers into a whole stack of masks.
It ships in the petty-paint pack, the ComfyUI-side integration for Petty Paint, Andrew Porter's web canvas that reimagines doodles through Stable Diffusion. When the app's layer stack arrives as RGBA tensors, this is the node that converts all their alpha channels into a usable mask batch in one step.
How it works
For each image in the batch it indexes the channel you pick - 0 red, 1 green, 2 blue, 3 alpha - and emits it as a 0–1 float mask. White is bright channel, black is dark channel, batch order preserved. That's the whole mechanism; the value is doing it for N images without a loop node or a per-image conversion.
The inputs and outputs
images- the IMAGE batch.channel- red, green, blue, or alpha.- Output:
MASK(batch).
Why it earns its keep
Two real uses. First, the app-pipeline case: the pack's own PettyPaintLoadImages gives you inverted alpha masks, but if you've composited or transformed images since, those masks are stale - re-extracting alpha here gives you masks that match the current tensors. Second, the "mask baked into a channel" pattern from other tools: anything that encodes a selection as a colored image (masks painted red, stencil packs, segmentation exports) becomes a real mask with one node.
One pack-wide quirk: the output is a Python list, not a single tensor - if a downstream node errors, slap an index on the connection.
Installing it
Same pack, same install - ComfyUI Manager, search "petty-paint-comfyui-node":
cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node
Restart ComfyUI. Declared dependency is Flask==2.1.2; no model files needed.
Common issues
Watch polarity on alpha. ComfyUI masks conventionally mark the kept region; raw alpha often marks transparency, so you may need to invert before feeding an inpaint or compositing node. And know that this node and PettyPaintImageToMask are functionally the same - this one just handles batches. If you're coming from core ComfyUI, its own ImageToMask does this too, so don't install the pack just for this; use it because you're already here.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| channel | COMBO | 4 options: red, green, blue, alpha |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |