PettyPaintImageToMask
Pull a channel out of an image and call it a mask
- images
- MASK
A mask is just a channel that happens to be used for selection. This node makes that literal: give it an IMAGE and pick a channel - red, green, blue, or alpha - and it returns that channel as a ComfyUI MASK. It's the simplest kind of utility: no cleverness, no conversion math you need to babysit, just channel extraction. It's part of the petty-paint pack, the ComfyUI-side integration for Petty Paint, Andrew Porter's web canvas that reimagines doodles through Stable Diffusion.
Why you'd actually use it
The classic case is alpha: an RGBA layer where transparency is the selection. Pull the alpha channel and suddenly your compositing and inpainting nodes have a real mask to work with. The other channels exist because plenty of pipelines paint masks into a specific channel - people bake a black-and-white selection into the red channel of an image all the time, and this is the node that gets it out.
How it works
For each image in your batch it indexes the chosen channel: channel 0 is red, 1 is green, 2 is blue, 3 is alpha. The result is a float mask in 0–1 range - white where the channel is bright, black where it's dark. The batch is preserved, so a batch of images becomes a batch of masks.
One thing to note: unlike the pack's file-based PettyPaintLoadImageMasks, this node works on tensors already in the graph. If your mask is sitting in a file on disk, use the loader; if it's flowing through the graph as an IMAGE, this is the one.
The inputs and outputs
images- the IMAGE batch.channel- red, green, blue, or alpha.- Output:
MASK.
Output comes back as a list rather than a single tensor - if a downstream node complains, throw an index at it. That's a pack-wide quirk.
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; nothing to download.
Common issues
The classic mistake is expecting alpha extraction to give you an "inverted" mask. ComfyUI's convention is masks mark the kept area; a raw alpha channel often marks the transparent area, so the polarity can look backwards depending on what you're feeding. If your inpaint fills the wrong side, flip the mask. And note the naming: this pack also ships PettyPaintImagesToMasks, which does literally the same channel extraction - one "image", one "images". They're near-duplicates; grab whichever reads better in your graph.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| channel | COMBO | 4 options: red, green, blue, alpha |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |