Nodes/comfyui_image_io_helpers/ImageLoadAsMaskByPath(ImageIOHelpers)
ComfyUI Node

ImageLoadAsMaskByPath(ImageIOHelpers)

Turn any color channel into a mask — stop hand-drawing them

By Ryuukeisyou·Created 57 years ago·Updated 57 years ago· 0
ImageLoadAsMaskByPath(ImageIOHelpers)
    • MASK
    file_path
    channel

    A mask in ComfyUI is just a single-channel image: one value per pixel, where white marks the region you're affecting and black marks what stays untouched. The question is where that mask comes from. Most people draw it by hand or generate it with a detector node. But if the mask already exists as an image - sitting in a file on disk, encoded in a color channel - ImageLoadAsMaskByPath(ImageIOHelpers) pulls it straight in.

    This node loads an image from a file path and extracts one channel as a MASK output. That's it, and that's the whole point: it converts an image into mask data, the thing your inpainting and compositing steps actually consume.

    The inputs that matter

    Only two, and both matter:

    • file_path - a STRING. Absolute path to the image on disk. Same rules as the pack's ImageLoadByPath: relative paths resolve from ComfyUI's working directory, so go absolute.
    • channel - an enum: alpha, red, green, or blue. Which channel becomes the mask.

    The channel picker is the feature. If you have a plain black-and-white mask, any channel works and you can stop caring. But a lot of real-world mask assets don't work that way: character-ID maps, seam/UV masks, and multi-region "mask textures" pack different zones into the red, green, and blue channels of one image. Pick red and you get region A; pick blue and you get region C. That's the workflow this node exists for.

    The MASK output wires into the standard mask sinks: Set Latent Noisy Mask for inpainting, ImageCompositeMasked to paste a regenerated region back onto the original, or any node with a MASK input. In the inpainting context, remember the semantics: white is what gets regenerated. If your image's channel has the region you want as black, the extracted mask comes out inverted - feed it through an Invert Mask node (or flip the region in the source) before it touches the sampler, or your "fix this area" becomes "re-roll everything else."

    How to install it

    cd ComfyUI/custom_nodes
    git clone https://github.com/Ryuukeisyou/comfyui_image_io_helpers
    

    Restart, and the node lives under ImageIOHelpers. Or ComfyUI Manager → search "comfyui_image_io_helpers". No models to download, no exotic dependencies - this is pure Pillow channel-splitting. The pack is tiny and the GitHub repo has been flaky (it 404s when fetched directly), so if a clone fails, that's the known issue, not you doing it wrong.

    When you'd skip it

    If your masks come from detectors (ADetailer-style face fixing, SAM, background removal), you don't need this - those nodes hand you a MASK directly. Reach for this one when the mask is already an image on disk, especially channel-packed multi-region masks. It turns an otherwise annoying "recreate the mask by hand" problem into a path and a dropdown.

    Categoryimage_io_helpers

    Inputs (2)

    NameTypeDefaultDescription
    file_pathSTRING
    channelCOMBO4 options: alpha, red, green, blue

    Outputs (1)

    NameTypeDescription
    MASKMASK