Nodes/petty-paint-comfyui-node/PettyPaintLoadImageMasks
ComfyUI Node

PettyPaintLoadImageMasks

Load masks from image files by channel

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
PettyPaintLoadImageMasks
  • images
  • MASK
channel

Lots of workflows ship masks as separate image files, and the question is always the same: which channel holds the mask? This node's answer is "whichever one you tell it." It loads image files from disk and pulls a chosen channel out as a proper ComfyUI MASK - alpha, red, green, or blue. It's the file-to-mask loader for the petty-paint pack, and it's tuned for RGBA layer files where the mask lives in the alpha channel.

The pack is the ComfyUI-side integration for Petty Paint, Andrew Porter's web canvas that reimagines doodles through Stable Diffusion. When the app produces a layer with its mask baked into a channel, this is how it comes back into the graph as a real MASK.

How it works

images takes a list of file paths (typed any, so the pack's path-producing nodes feed it directly). Each file is opened, EXIF-transposed, and converted to RGBA if it isn't already. Then the node pulls the channel you picked and normalizes it to a 0–1 float tensor. For alpha it inverts - black becomes the masked-out region, matching ComfyUI's convention where masks mark the kept area.

The channel dropdown defaults to alpha first, which is the giveaway for how this is meant to be used: the app's layers are RGBA, and alpha is where the transparency lives.

The one that will bite you

There's a real bug in the shipped code worth knowing about. The masks.append(...) call sits outside the loop over images - so even if you feed it multiple paths, you get back only the last image's mask. It's not a batch loader, no matter how it looks. Feed it one path at a time, or expect just the final file's mask. That's the kind of thing that produces "why is my mask the wrong character?" confusion, so now you know.

The inputs and outputs

  • images - any; image file path(s) to load.
  • channel - alpha, red, green, or blue.
  • Output: MASK.

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 downloads.

Common issues

Beyond the single-mask gotcha: a file with no matching channel yields a blank 64×64 zero mask rather than an error - so a wrong channel choice silently gives you an all-black mask. Pick alpha for RGBA layers, and remember if your source is already a ComfyUI IMAGE tensor rather than files on disk, the sibling PettyPaintImageToMask / PettyPaintImagesToMasks nodes do the same channel extraction without touching the filesystem.

Categorymask

Inputs (2)

NameTypeDefaultDescription
images*
channelCOMBO4 options: alpha, red, green, blue

Outputs (1)

NameTypeDescription
MASKMASK