Nodes/ComfyUI LoadImageWithFilename/Load Image With Filename
ComfyUI Node

Load Image With Filename

The stock Load Image node, plus the one output it was missing

By thalismind·Created about a year ago·Updated about a year ago· 8
Load Image With Filename
    • image
    • mask
    • filename
    image

    If you've ever tried to save an image with the same name it came in with, you've probably discovered that ComfyUI's core Load Image node just... doesn't tell you the filename. It hands you the image tensor and a mask and that's it - the name of the file you picked from the dropdown evaporates the moment it's loaded. This node fixes exactly that, and nothing else.

    LoadImageWithFilename is a drop-in swap for the built-in Load Image node - same picker, same behavior - with one extra wire coming out the side: filename, a plain string of whatever file you selected. That's the whole pitch. It's not a fancier loader, it's not smarter, it doesn't do batching. It's the stock node with the one missing piece of metadata restored.

    Why this is even a thing

    This isn't a hypothetical itch - it's a recurring "how do I do this" post on r/comfyui: someone builds a batch pipeline (upscaling game assets, renaming outputs, whatever), and hits a wall because the filename data just isn't available anywhere downstream. The workarounds people reach for are things like KJNodes' Widget-to-String or hacking a Replace-Text node against a full filepath string - clever, but indirect. This pack's answer is more direct: put the filename output on the loader itself. The pack's README even points at the upstream ComfyUI GitHub issue asking for this feature, which as of this writing still hasn't landed in core. So this exists to fill a real gap, not to reinvent something that already works fine.

    The inputs and outputs that matter

    There's exactly one input: image, the same dropdown you know from the stock node - pick a file that's already in your ComfyUI input folder (or one you just uploaded through the UI).

    Three outputs:

    • image (IMAGE) - the loaded image tensor, same as always.
    • mask (MASK) - the alpha-channel mask, if the source file has one. If it doesn't, you'll get an empty/blank mask back, same as the stock node.
    • filename (STRING) - the name of the file you picked. This is the new part. Wire it into anything that wants a string: a Save Image With Filename node from this same pack (the obvious pairing - load with a name, save with that name), a text overlay, a log, whatever your workflow needs.

    Installing it

    Two ways in:

    • ComfyUI Manager - search ComfyUI LoadImageWithFilename, install, restart ComfyUI.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/thalismind/ComfyUI-LoadImageWithFilename, then restart.

    There's no separate install script and nothing to download afterward - the whole pack is one nodes.py file, and it just needs PIL, PyTorch and NumPy, all of which any working ComfyUI install already has. After restart you'll find LoadImageWithFilename (and its siblings) under the image category.

    Common issues

    Honestly, there's not much to trip over - it's a thin wrapper around a node you already know. The couple of things worth knowing:

    It reads from the input folder like normal Load Image does. If your dropdown is empty or missing a file you expect, that's a ComfyUI input-folder issue, not something this node changes.

    The mask output is genuinely conditional. If your source image has no alpha channel, don't expect a meaningful mask out of this - that's inherited behavior from the node it's based on, not a bug in the filename addition.

    This single-image node has no batch mode. If you're trying to process a whole folder and track filenames across the batch, that's a different node in the same pack - LoadImageFolder - not this one. Don't reach for this node and then wonder why it won't take a directory path; it's built for one file at a time by design.

    Categoryimage

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png

    Outputs (3)

    NameTypeDescription
    imageIMAGE
    maskMASK
    filenameSTRING