ImageLoadAsMaskByPath(IOHelpers)
Load a mask from a file path — and pick which channel does the work
- MASK
ComfyUI's built-in Load Image only browses files inside ComfyUI/input/. If your mask lives somewhere else - sitting next to a render on a network share, written by a batch script, exported from an editor - you need a loader that takes a literal path. ImageLoadAsMaskByPath(IOHelpers) does exactly that, and it skips the full image entirely: you get a MASK wire, not an IMAGE.
That's the move for mask-based inpainting and compositing. Masked editing still owns the one thing whole-image edit models can't do: bit-identical pixels outside the mask. When you want to inpaint a region without touching the rest of the frame, a properly loaded mask is the whole ballgame.
How it works
The node opens your file with PIL, applies exif_transpose (so phone photos aren't sideways), forces the image to RGBA, and then pulls a single channel based on the channel dropdown. That channel is normalized from 0–255 to a 0.0–1.0 float tensor and returned as a batch-of-one mask.
One convention to internalize: the alpha channel comes back inverted (the code computes 1 − alpha). That's deliberate - ComfyUI masks use white = the area you keep or edit, and transparency is alpha 0, so transparent regions map to white. Red, green and blue are read as-is, no inversion.
Inputs and outputs
- file_path - paste the path. No dropdown, no browsing: the string is the path, exactly as the code will
Image.open()it. - channel -
alpha,red,greenorblue. Pick the one that encodes your mask.
Output is a single MASK, which wires into anything that takes a mask: an inpaint workflow via a masked KSampler, compositing, mask math, you name it. If your mask is stored as a separate grayscale "key" image, red (or green/blue, same thing for grey) is the usual pick.
Installing it
The whole pack is one dependency-free file from GitHub user Ryuukeisyou - no requirements.txt, no models to download. ComfyUI Manager → search "comfyui_io_helpers" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Ryuukeisyou/comfyui_io_helpers
Restart ComfyUI and the nodes appear under "io_helpers".
Common issues
- Wrong path = hard crash. Unlike the pack's base64 loader, this node has no error handling: a typo'd or missing file raises
FileNotFoundError. Double-check the path before you blame the node. - Relative paths resolve against ComfyUI's working directory. Absolute paths are the safe move.
- No alpha? Empty mask. If the file has no alpha channel (say, a JPEG), the alpha mask comes back as a blank 64×64 tensor - which will surprise you downstream. For files without transparency, choose a color channel instead.
- "My mask is backwards!" With alpha, that's usually the inversion working as designed. White = transparent = the region a masked edit will touch. If you genuinely want it flipped, invert the mask downstream.
It's a small, single-purpose node - and for anyone who keeps masks as files, it plugs a hole the core Load Image just doesn't cover.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| channel | COMBO | 4 options: alpha, red, green, blue |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |