ComfyUI Node

Download Image

Grab an image from a URL and load it as a tensor in one step

By alchemine·Created about a year ago·Updated 2 days ago· 2
Download Image
    • image
    • file_path
    url
    dir_pathoutput/images

    DownloadImage does exactly what it says: fetches an image from a URL, saves it into your ComfyUI output directory, and hands you back both the loaded image tensor and the file path it was saved to. It's the "feed this internet image into my graph" node - wire its image output straight into a sampler, a ControlNet preprocessor, an image-to-video node, whatever.

    The name undersells the useful bit: most "load an image from URL" workflows make you download it by hand, find where it landed, then load it with a LoadImage node. This collapses all that into one step, and it remembers what it's done - if the file already exists, it just loads it and skips the network call. That idempotence is why it's so pleasant to drop into a workflow you re-run constantly.

    How it works

    The node takes your url, extracts the file extension from it, and saves the download into dir_path (relative to the ComfyUI output directory, default output/images). Filenames are auto-generated: an 8-character MD5 hash of the URL plus a numeric index - so the same URL always lands in the same folder without overwriting your other files, and re-running the same URL short-circuits to a local load. It returns the file's path (relative to the output dir) and a decoded IMAGE tensor, ready to wire onward.

    Inputs and outputs

    Two inputs, both dead simple:

    • url - the image URL. Required.
    • dir_path - destination directory relative to your ComfyUI output folder. Default output/images; that default is genuinely reasonable, so most people never touch it.

    Outputs: image (the IMAGE tensor) and file_path (the relative path string of the saved file). Wire image into whatever wants it; file_path is there for when you also need to tell something else where the file lives.

    Install

    Part of ComfyUI-Alchemine-Pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alchemine/comfyui-alchemine-pack
    pip install -r requirements.txt
    

    Or via ComfyUI Manager (search "ComfyUI-Alchemine-Pack"). The only dependency is python-dotenv, and there are no model downloads. The requests library it uses is already part of ComfyUI's environment.

    Common issues

    The first failure mode is a blocked or signed URL. Direct image URLs work; pages that serve a browser shell instead of the raw image will save a useless HTML file (look at what got written if nothing loads). Hotlink-protected hosts like some image boards will 403 - the node raises on a non-200. Second, the filename index is derived from the folder contents, so two different URLs to the same folder get sequential names, which is fine, but deleting one file can cause a re-download to reuse a name and collide. Third: it's a synchronous requests.get with no timeout in sight - a hanging URL will hang your queue until the request gives up.

    CategoryAlcheminePack/Lora

    Inputs (2)

    NameTypeDefaultDescription
    urlSTRING
    dir_pathSTRINGoutput/images

    Outputs (2)

    NameTypeDescription
    imageIMAGE
    file_pathSTRING