Nodes/RUI-Nodes/加载图像(带文件名) / Load Image With Name
ComfyUI Node

加载图像(带文件名) / Load Image With Name

Load Image, but it hands you the filename it used

By rui40000·Created 3 years ago·Updated 6 days ago· 17
加载图像(带文件名) / Load Image With Name
    • IMAGE
    • MASK
    • filename
    image

    Load Image With Name is what you get when someone takes ComfyUI's stock Load Image node and asks "but what if I need to know which image I loaded?" It behaves exactly like the native node - same input directory picker, same drag-and-drop upload - with one extra output: the filename, without the extension, as a string.

    That tiny addition unlocks a genuinely useful pattern. Batch processing where each output file should keep the name of its input, so a folder of cat_01.jpg, cat_02.jpg, ... comes out as cat_01_processed.png, cat_02_processed.png instead of a pile of ComfyUI_00001_... names. Or feeding the filename into a prompt, a save path, or a caption so downstream nodes know what they're working with. If you've ever built a loop that processes twenty images and had to manually map outputs back to inputs, you know exactly why this exists.

    How it works

    The implementation is a close copy of ComfyUI's own loader, so everything you're used to carries over: it lists files from folder_paths.get_input_directory(), supports upload, and the MASK output is the image's alpha channel - same convention as the native node. The filename is pulled from the path with the extension stripped: upload test_image.png and filename outputs test_image.

    The inputs/outputs that matter:

    • image - dropdown from your input directory (or upload button).
    • Outputs: IMAGE (the pixels), MASK (alpha channel, in ComfyUI's standard form), and filename (base name, no extension).

    One subtlety: because the filename is computed from the actual path at execution time, it stays correct even in batch contexts where the dropdown selection is being driven programmatically. The node also hashes the file for change detection, so replacing an image on disk with a same-named file properly re-triggers the graph instead of serving a stale cache.

    Installing it

    Part of the RUI-Nodes pack ("Rui-Node🐶"), a bilingual Chinese/English node collection. Install the pack once via ComfyUI Manager (search "RUI-Nodes") or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/rui40000/RUI-Nodes
    cd RUI-Nodes
    pip install -r requirements.txt
    

    Then restart ComfyUI. Base requirements are just torch, numpy, Pillow, and requests - nothing extra for this node.

    Where people get burned

    Almost nowhere, which is the nice thing about a faithful clone. The only thing to keep straight: the filename output is the base name without extension, so if you're building a save path, remember to re-append your output extension yourself. And as with any input-folder loader, images you upload land in the same shared directory all your other loads use - fine in practice, just don't expect per-workflow sandboxing.

    If you need to load from an arbitrary absolute path instead of the input directory, the same pack's Load Image By Path is the sibling for that job.

    CategoryRui-Node🐶/文件存储与加载📁

    Inputs (1)

    NameTypeDefaultDescription
    imageCOMBO从 input 目录选择图像,或点下方按钮上传。 与原生加载节点的区别:额外输出不带后缀的文件名, 便于让输出文件沿用原名,批量处理时不会张冠李戴。

    Outputs (3)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK
    filenameSTRING