Nodes/ComfyUI-MDSNodes/Load Image (With Path)
ComfyUI Node

Load Image (With Path)

Where It Lives

By MarwanDSAI·Created about a month ago·Updated a day ago· 1
Load Image (With Path)
    • IMAGE
    • MASK
    • filename
    • full_path
    • directory
    image

    Load Image (With Path) is the stock Load Image node with its pockets turned out. You get the decoded IMAGE tensor and the alpha MASK just like usual - and then, for free, you also get the filename, the absolute path, and the parent directory as three STRING outputs. It's the "tell me where this thing actually is" version of a loader, and once you've wanted that, you want it constantly.

    The standard loader hands you pixels and forgets the file ever existed. That's fine until you're doing batch work: saving outputs next to their source images, building filenames that echo the input, logging which file a render came from, or feeding a path into a node that writes somewhere specific. For the model-testing workflow this pack grew out of, keeping the source path alive in the graph is what lets you organize a folder of tests instead of dumping everything into a flat pile.

    How it works

    Under the hood it's essentially the core loader, reimplemented: it opens the file with Pillow (with EXIF transpose applied so phone photos come out the right way up), converts to an RGB tensor, and pulls the alpha channel into an inverted MASK for inpainting - same behavior you already know. On top of that it captures os.path.basename, os.path.dirname, and the absolute path of the resolved file, and ships them out as strings.

    Two deliberate quirks live in the source, and both are worth knowing:

    • IS_CHANGED returns NaN, the ComfyUI idiom for "always rerun." That means the node re-reads the file on every queue, so if you edit the image on disk between runs you get the fresh version - no cache fighting you. The flip side is it's a permanently dirty node, which defeats caching for everything downstream of it.
    • If the file can't be found or fails to open, it returns a fallback: a 64x64 black tensor, a blank mask, and empty strings, instead of an error. You won't get a helpful exception; you'll get a silent black 64x64.

    The outputs that matter

    • IMAGE and MASK - identical to the stock loader; feed them into VAE encode, ControlNet, or an upscaler.
    • filename (STRING) - photo.png.
    • full_path (STRING) - the absolute path on disk, e.g. E:\ComfyUI\ComfyUI\input\photo.png.
    • directory (STRING) - the folder holding it.

    The path strings are the reason to pick this node over the core loader. Drag filename into your save-prefix, route directory to a node that needs a target folder, done.

    Installing it

    It ships in MarwanDSAI/comfyui-mdsnodes. ComfyUI Manager: search "ComfyUI-MDSNodes", install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MarwanDSAI/comfyui-mdsnodes
    

    Restart, and no pip step - the pack has an empty requirements.txt and zero declared dependencies.

    Gotchas

    The silent black-image fallback is the one that will bite you. A missing file doesn't error - it quietly gives you a 64x64 black frame, and if you're not watching, you'll chase a "why is everything black" mystery that the node caused. If you're doing long batch runs, also budget for the always-rerun behavior: every queue re-reads the file, which is exactly what you want for hot-reloading but a small tax on raw throughput.

    CategoryMDSNodes/image

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBOSelect an existing image from the input directory or upload a new file.

    Outputs (5)

    NameTypeDescription
    IMAGEIMAGEThe decoded image tensor (RGB) formatted for VAE, ControlNet, or upscalers.
    MASKMASKThe alpha transparency mask channel (inverted for inpainting).
    filenameSTRINGThe clean file name including extension (e.g., photo.png).
    full_pathSTRINGThe full absolute file path on disk (e.g., E:\ComfyUI\ComfyUI\input\photo.png).
    directorySTRINGThe parent folder directory path where the image is stored.