Nodes/comfyui-save-image-pro/Load Mask from URL (Pro)
ComfyUI Node

Load Mask from URL (Pro)

Turn a URL's Color Channel Into an Inpainting Mask

By weekii·Created about a year ago·Updated about a month ago· 5
Load Mask from URL (Pro)
    • masks
    urls
    timeout30
    verify_ssltrue
    channelred

    Say someone hands you a mask that's hosted online - an alpha PNG, a black-and-white matte, a segmentation map. In stock ComfyUI that's a whole little ritual: download the file into input, load it with LoadImage, split out a channel, invert it, convert it. Load Mask from URL (Pro) collapses all of that into one node: paste a URL, pick a channel, and out comes a proper MASK tensor. It's the focused sibling of the pack's LoadImageFromURLPro, and it's built for the one job that node only does incidentally.

    Why masks matter at all: masked inpainting is still the way to edit exactly one region and leave every other pixel bit-identical - instruction-edit models can't promise that. In ComfyUI a mask is a single-channel tensor where white marks the region that gets touched. If your mask source already lives on the web, this node is the bridge between "a URL" and "an inpaint region."

    How it works

    Same fetch pipeline as its image sibling - HTTP GET via requests with a 30-second timeout and HTTPS verification on by default, EXIF rotation applied so nothing arrives sideways. Then it converts the image to RGBA and pulls out the channel you asked for:

    • red / green / blue are extracted as-is: black pixels become 0, white pixels become 1.
    • alpha is auto-inverted (1 − alpha). So a PNG with a transparent background yields a mask that's white where the image is transparent - preview it before you commit, because which side ends up white depends entirely on how your source encoded it.

    The output is a list of MASK tensors, so one node hands you a whole batch of masks for downstream iteration.

    Inputs are about as minimal as it gets: urls (multiline, one per line, blank lines ignored) and channel (an enum with exactly red, green, blue, alpha - default red). If your source is a standard black-and-white mask where the region is white, any of the color channels gives the same result, so just leave it on red unless your image is genuinely single-channel-per-region. alpha is the one to reach for with cutout/transparency PNGs. As with the image node, the shipped build also exposes a timeout (1–300s) and a verify_ssl toggle for self-signed certs.

    Installing it

    It ships in comfyui-save-image-pro, so install the pack once and you get both URL nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/weekii/comfyui-save-image-pro.git
    

    or search "ComfyUI Save Image Pro" in ComfyUI Manager, then restart. Dependencies are requests, pillow, piexif, pillow-avif-plugin - nothing heavy, no models to download.

    Gotchas

    • All-black output usually means all URLs failed. The node logs each failure and skips it; if nothing loads it falls back to a 64×64 black mask - which in most inpaint setups means "nothing to edit," so the run looks like it silently did nothing. Check the console for Error reading image from URL.
    • The alpha direction catches people. Because it's inverted, a normal cutout PNG gives you a mask that highlights the transparent area. If you wanted the subject masked, invert again downstream or pick a color channel instead.
    • Batch is serial. A stack of URLs fetches one at a time, 30s per request, so a long list plus a slow host is a long queue step.
    • Name collision if you run comfyui-easyapi-nodes too - its original LoadImageFromURL and this Pro variant sit side by side in search and do overlapping things.

    From there it's the standard wiring: masks out goes into Set Mask, an inpaint sampler, or conditioning setup, and your mask-driven workflow can pull its input straight from a URL instead of a folder.

    Categoryimage

    Inputs (4)

    NameTypeDefaultDescription
    urlsSTRING图像URL地址,每行一个URL
    timeoutINT301–300单个URL请求超时时间(秒)
    verify_sslBOOLEANtrue校验 HTTPS 证书;如遇自签名证书可关闭
    channelCOMBOred用于提取遮罩的颜色通道

    Outputs (1)

    NameTypeDescription
    masksMASK