Nodes/ComfyUI-off-suite/Cached Image Load From URL
ComfyUI Node

Cached Image Load From URL

Load Images From Any URL, and It Remembers Them

By Off-Live·Created 3 years ago·Updated 2 years ago· 0
Cached Image Load From URL
    • images
    • masks
    • has_image
    url
    keep_alpha_channelfalse
    output_modefalse

    Need to pull a reference image into ComfyUI straight from a URL, without downloading it by hand into your input folder every time? This node does that - and it's smart about it, caching each URL to disk with ETag-based checks so repeat loads don't re-download the whole file. It also understands more URL shapes than you'd expect, which turns out to be its real superpower.

    It's part of ComfyUI-off-suite, and it's one of the more polished things in the pack - the loader logic is borrowed from the art-venture utility nodes, and it shows. It's been quiet on the maintenance front since mid-2024, but this is a "works and stays working" kind of node.

    What you plug in

    • url - one URL per line (it's a multiline field). It understands:
      • https:// / http:// - normal web images, fetched with caching
      • data:image/png;base64,... - base64 images embedded right in the string
      • file:///path/to/image.png - a local file
      • /view?filename=... - ComfyUI's own internal preview links, including type=input/output/temp, so you can re-load an image that's already inside ComfyUI
    • keep_alpha_channel - default off. On, and a PNG's alpha channel is preserved into the mask; off, and it's flattened to RGB.
    • output_mode - default "batch". Flip it to "list" if your images are different sizes; batch mode will throw on mixed sizes rather than silently degrade.

    What comes out

    • images (a list) - the loaded images.
    • masks (a list) - the alpha channels when present. Note these are inverted (mask = 1 - alpha), ComfyUI-style.
    • has_image (a BOOLEAN) - False if nothing loaded, in which case you get a 64×64 black placeholder instead of a crash.

    That has_image output is the underrated part: it lets you branch downstream ("if no image came back, take the other path") instead of the queue dying on a 404.

    The caching bit, and its one wrinkle

    Each URL is hashed to a filename in a template_cache/ folder created relative to ComfyUI's working directory, with ETag-based If-None-Match revalidation. Translation: fetch once, and later runs are near-instant and polite to the server. The wrinkle is that the cache folder lives in the working directory of the ComfyUI server process, not in input/ or temp/. If you run ComfyUI from a different directory or as a service, that's where the cache silently lands - harmless, but it'll surprise you the first time you go looking for it.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/Off-Live/ComfyUI-off-suite
    # or: ComfyUI Manager → search "ComfyUI-off-suite"
    

    No extra pip packages - it uses requests, which ComfyUI already bundles. If you're loading lots of images, keep output_mode on list when sizes vary, and remember the whole thing is fetch-at-queue-time: a dead link means a queue error, which is why the has_image output exists.

    CategoryOFF

    Inputs (3)

    NameTypeDefaultDescription
    urlSTRING
    keep_alpha_channeloptBOOLEANfalse
    output_modeoptBOOLEANfalse

    Outputs (3)

    NameTypeDescription
    imagesIMAGE
    masksMASK
    has_imageBOOLEAN