Nodes/comfyui-subfolderimageloader/Subfolder Image Loader
ComfyUI Node

Subfolder Image Loader

Tired of scrolling 300 files? Load images from subfolders instead

By rdomunky·Created about a year ago·Updated about a year ago· 2
Subfolder Image Loader
    • image
    • mask
    • filename
    • width
    • height
    subfolder
    imageexample.png
    load_masktrue

    The standard Load Image node is fine - right up until your input/ folder turns into a 300-file flat pile of every image you've ever touched. That's the exact moment you want this: a drop-in replacement for Load Image that reads your input directory's subfolders and lets you pick an image in two steps - first the folder, then the file. Same five outputs as the stock node, same way of wiring in, zero new dependencies. If your input is organized, this just removes friction.

    How it works

    The node is built on two enums. The subfolder dropdown lists the direct subfolders of ComfyUI's input/ directory (leave it empty for the root). When you change it, a small JavaScript extension POSTs to the pack's /subfolder_loader/refresh API endpoint, gets back a filtered image list, and swaps out the options on the image widget. Pick an image and it's loaded the standard way: the filename keeps its subfolder/ prefix so ComfyUI's own get_annotated_filepath() resolves it (which is also where the path-traversal validation happens - that's not this node reinventing security, it's using the platform's).

    Behind the scenes it's Pillow converting whatever you feed it - PNG, JPG, WebP, BMP, TIFF - to RGB, then into a normalized float tensor. load_mask (default on) pulls the alpha channel out of RGBA files as a proper MASK tensor before that conversion. So yes, PNGs with transparency behave exactly like they do in stock Load Image.

    Two quirks worth knowing. First, the image list is cached for about five seconds, so a file you just dropped into the folder may not appear immediately - right-click the node and hit "🔄 Refresh Files" (or just wait). Second, only direct subfolders are supported. input/portraits/ works; input/portraits/studio/ does not. Empty folders still show up in the list, which is mildly annoying but harmless.

    The inputs and outputs that matter

    You'll set two things:

    • subfolder - the folder in input/, empty string for root. This is the whole point of the node.
    • image - filtered to whatever's in the selected subfolder. The load_mask toggle below it only matters if you're working with transparent PNGs.

    The five outputs are identical to Load Image: image (IMAGE) into your VAE encode / conditioning, mask (MASK) into anything that takes a mask for inpainting or compositing, and filename (STRING), width (INT), height (INT) for bookkeeping. Nothing about the graph changes when you swap the node in.

    Installing it

    ComfyUI Manager is the easy path: search for "Subfolder Image Loader" and install. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/rdomunky/comfyui-subfolderimageloader.git
    

    Then restart ComfyUI. There's no requirements.txt and no models to download - it leans entirely on Pillow, numpy and torch, all of which ComfyUI already ships. This is about as painless as custom nodes get.

    Troubleshooting

    • Images not appearing - they need to be in input/ (or a direct subfolder) and in a supported format. TIFF works, which is more than the stock loader will say.
    • Subfolder list stale after adding a new folder - use the right-click refresh, or restart.
    • The dropdown didn't visually update - the README admits a ComfyUI UI quirk where the image list sometimes needs a mouse movement over the node to redraw. Functionally it's correct; it just looks laggy.
    • UI widgets not rendering at all - the pack ships a web/ directory; if the JS isn't loading, that's a sign the clone or Manager install didn't register WEB_DIRECTORY.

    Honestly, for a node this small there's not much to go wrong. If your workflow is drowning in a flat input folder, it's a five-minute install for a real quality-of-life win.

    Categoryimage/loaders

    Inputs (3)

    NameTypeDefaultDescription
    subfolderCOMBOSelect a subfolder from your input directory. Leave empty for root folder. The image list will update automatically when you change this.
    imageCOMBOexample.pngChoose an image from the selected subfolder. This list is filtered based on your subfolder selection.
    load_maskoptBOOLEANtrueExtract alpha channel as mask from RGBA/transparent images. Disable if you don't need transparency masks.

    Outputs (5)

    NameTypeDescription
    imageIMAGE
    maskMASK
    filenameSTRING
    widthINT
    heightINT