Nodes/zhangp365/ComfyUI-utils-nodes/Load Image without Listing Input Dir
ComfyUI Node

Load Image without Listing Input Dir

Load Image without Listing Input Dir

By zhangp365·Created 2 years ago·Updated 5 months ago· 134
Load Image without Listing Input Dir
    • image
    • mask
    • enabled
    • filename
    • width
    • height
    image
    enabledtrue
    input_image_path

    The default LoadImage node builds its dropdown by calling os.listdir on your input/ folder every time the graph loads or refreshes. Fine when that folder has a dozen files. Not fine when it has thousands - which happens fast if you're doing anything batch-oriented, running automated pipelines, or just never cleaning up. The README states the problem plainly: "when there are a lot of images in the input directory, loading image with os.listdir can be slow. This node avoids using os.listdir to improve performance." That's the entire pitch, and it's a real one - directory listing is O(n) and ComfyUI does it synchronously on the main thread.

    The mechanism is in the optional input_image_path field: instead of forcing the node to enumerate every file in input/ to populate a dropdown, you can hand it a direct path and skip the listing step entirely. That's the actual trick - not a faster listing algorithm, just avoiding the need to list at all when you already know what you want.

    Inputs: image is required and shows up as the usual dropdown, but the interesting one is optional: input_image_path, a plain string where you can type or wire in a path directly. enabled (default true) follows the pack's standard bypass-switch pattern.

    Outputs: more than the stock LoadImage gives you. You get image and mask as expected, plus enabled (a BOOLEAN passthrough of the input, handy for chaining into other switch-pattern nodes in this pack), filename (a STRING - useful if you're doing anything that needs to know or log which file actually got loaded), and width/height as INTs so you're not stacking a separate NeedImageSizeAndCount node on top just to know the dimensions.

    Install: search "ComfyUI-utils-nodes" in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zhangp365/ComfyUI-utils-nodes
    

    Restart afterward. No extra dependencies for this specific node - it's a Python-level filesystem optimization, not something that needs a model or an API key.

    What actually goes wrong:

    • If you skip input_image_path and rely on the dropdown, you haven't actually dodged the slow-listing problem - the dropdown still has to be populated from somewhere. The performance win only materializes when you feed a path directly, typically from an upstream node that already knows the filename (a batch iterator, a string built from a counter, etc.) rather than picking from the UI each time.
    • Dependency hell is the standing complaint across the whole ComfyUI custom-node ecosystem - packs installing conflicting Python requirements into one shared environment. This node itself carries no dependencies, so if something breaks on install, it's almost certainly a conflict from another pack sharing your environment rather than this one specifically. Worth checking your ComfyUI console output for the actual import error before assuming this node is at fault.
    • A path that doesn't resolve - wrong slashes on Windows, a relative path assumed relative to the wrong working directory - will fail the load. Since this node exists specifically to bypass ComfyUI's normal file-discovery mechanism, you lose the safety net of the dropdown only showing files that actually exist; double-check the path is exactly right rather than assuming ComfyUI will catch a typo for you.
    Categoryutils/image

    Inputs (3)

    NameTypeDefaultDescription
    imageCOMBO0 options:
    enabledoptBOOLEANtrue
    input_image_pathoptSTRING

    Outputs (6)

    NameTypeDescription
    imageIMAGE
    maskMASK
    enabledBOOLEAN
    filenameSTRING
    widthINT
    heightINT