Nodes/Smart Load Image/Load Image (Smart)
ComfyUI Node

Load Image (Smart)

The Load Image node that doesn't clobber your selection on reload

By aiark032025·Created 3 months ago·Updated 3 months ago· 1
Load Image (Smart)
    • IMAGE
    • MASK
    base_folderoutput
    subfolder(root)
    image

    Every workflow that doesn't start from a blank latent starts the same way: a Load Image node pulling a file in. It's the front door to img2img, inpainting, ControlNet conditioning, IP-Adapter reference passes, upscale chains - anything that feeds existing pixels into a model. And it's also where a couple of the built-in loaders' rough edges show up fastest. The built-in Load Image reads from the input folder, Load Image (Outputs) reads from output, neither understands subfolders, and the combo has a habit of snapping to the newest file when you reload a workflow - silently wiping whatever you had selected. Reload, reselect, reload, reselect.

    Load Image (Smart) is a single node that cleans up most of that list. One base_folder dropdown for output or input, one single-level subfolder dropdown, image files only (videos filtered out), a Refresh button that re-reads the folder without dropping your current pick, and a selection that survives reloads. It's a small pack with an honest name, MIT-licensed, and it's one of those utility nodes you install once and forget is a third-party thing.

    What it actually fixes

    The headline feature is selection persistence. The README calls out the built-in remote combo's "clobbering to the newest file" on refresh, and anyone who has ever chain-ran img2img passes knows the pain. Here, your chosen file stays chosen through workflow reloads, frontend refreshes, all of it. If the file still exists, it stays selected.

    Beyond that, the practical wins:

    • Videos are filtered out. If your output folder is full of .mp4s from a video-gen session, the stock loader lists them. This node checks mimetypes via ComfyUI's own file filter and only shows images. That's a genuinely nice touch if you do any video work at all.
    • Subfolder support - single-level, so output/captures/ works but nested trees don't (by design).
    • Empty-safe. No selection, or a folder with no images, returns a 1×1 placeholder instead of throwing. The graph keeps running.

    How it works

    The node is really two halves. On the backend, routes.py registers two read-only endpoints - /smartload/subfolders and /smartload/images - that list what's available in the currently selected base folder. On the frontend, web/loadImageSmart.js populates the combos by calling those, and drives the Refresh and Upload buttons (upload reuses ComfyUI's existing secured /upload/image endpoint). The image widget stores an annotated value like captures/foo.png [output] - the same contract ComfyUI's mask editor uses - and that value, not the dropdowns, is what actually resolves on load.

    Path resolution goes through a strict allowlist (output and input, both validated with commonpath containment checks), so no directory-traversal surprises. The actual image decoding mirrors core LoadImage: EXIF-transposed, animated GIF/WebP frames handled, alpha channel turned into an inverted MASK the way ComfyUI always does. It even hashes the file on disk so the node only re-runs when the file itself changes, which means it doesn't poison ComfyUI's execution cache.

    The inputs and outputs that matter

    Only three inputs, and you mostly touch one:

    • base_folder - output or input, defaults to output. This is the deliberate difference from the built-in loader: it's aimed at feeding saved outputs back into the graph.
    • subfolder - one level deep, defaults to (root).
    • image - the actual file picker.

    Outputs are the standard pair: IMAGE ([B,H,W,C]) and MASK ([B,H,W], black/zero when there's no alpha). Wire IMAGE into VAE Encode for img2img, a ControlNet preprocessor, an IPAdapter, or straight into Preview Image to eyeball what the last run saved.

    Installing it

    No dependencies, no model files, nothing to download beyond the pack itself - it only uses what ComfyUI already ships. Easiest route is ComfyUI Manager: search "Smart Load Image". Or the manual way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aiark032025/comfyui_smart_load_image
    

    Then restart ComfyUI. The node shows up under the image category as "Load Image (Smart)". If it doesn't appear, the restart is the step people skip - the frontend extension and API routes only register at startup.

    Gotchas worth knowing

    • A black 1×1 image is the designed empty state, not a bug. If you see one, you just haven't picked a file yet.
    • Subfolders are single-level only. Deeply nested folder trees won't show up.
    • Adding base folders means editing code. ALLOWED_BASES in common.py is the security allowlist; anything you add must be a directory type folder_paths understands. It's clearly documented in the README, but treat it as a "know what you're doing" edit.

    One honest caveat: this is a young, small pack with essentially no community footprint yet. Fine for a utility this scoped - but given ComfyUI's history with unvetted custom nodes, a quick skim of the ~300 lines of source before you install is cheap insurance.

    Categoryimage

    Inputs (3)

    NameTypeDefaultDescription
    base_folderCOMBOoutput2 options: output, input
    subfolderCOMBO(root)1 options: (root)
    imageCOMBO0 options:

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK