Nodes/comfyui-imgmake/SelectImageName
ComfyUI Node

SelectImageName

Pick one image name out of a list — just watch the off-by-one

By dafeng012·Created 2 years ago·Updated 2 years ago· 17
SelectImageName
    • image_name
    imagelist
    selected_image_index1

    SelectImageName is a tiny helper that answers one question: "of all the images in this folder, what's the name of the Nth one?" It takes the comma-joined image_list string that LoadImageListPlus or LoadImagesFromPath_lp produce, plus an index, and returns that image's name. You'd use it when you want to grab one specific keyframe's filename and feed it somewhere that needs a path - it's the pointer-finger node of the pack.

    That's the entire job. No loading, no generating, just string surgery. It's the sort of node that exists because the pack's own loaders hand you filenames as a flat string and somebody, somewhere, needed to get one of them back out.

    How it works (and the trap)

    Under the hood it splits the input string on commas and indexes the resulting Python list. Two things to know:

    1. It's zero-indexed, but the widget starts at 1. The selected_image_index widget has a minimum of 1 and defaults to 1. Python list indexing is 0-based, so index 1 gives you the second item. There is no way to select the first item through the widget - the min is 1 and index 0 is unreachable from the UI. To get the second image name, index 1 works fine; to get the Nth, set the widget to N. Just know you're always one off from the "first".
    2. The list comes with spaces. The pack's loaders join names with ", " (comma-space), but this node splits on "," alone. So the second and later names come back with a leading space - " 00020" instead of "00020". If you're building a path with the result, strip it or it'll silently point at a file that doesn't exist.

    Inputs and output

    • imagelist - the STRING from a loader node's image_list output.
    • selected_image_index - INT, 1 to 9900, default 1.
    • Output: image_name - the selected name (with a leading space if it's not the first).

    Installing it

    It ships in comfyui-imgmake, so the usual routine - ComfyUI Manager (search comfyui-imgmake) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/dafeng012/comfyui-imgmake
    

    Restart. No dependencies at all; it's a pure string function.

    Troubleshooting

    • "Index out of range" - you asked for an index beyond the number of items in the list (remember the list is the names, which for LoadImagesFromPath_lp only includes PNGs).
    • Path doesn't resolve downstream - almost certainly the leading-space artifact; feed the output through a strip or text-format node before building a path.
    • Got the second image when expecting the first - yes, that's the 1-vs-0 indexing. Adjust the widget.

    This node is a genuine edge case even within its own pack - you'll only reach for it in the handful of workflows that need a specific filename routed somewhere. When you do, it's the difference between "ugh, why is my path one character off" and understanding exactly why. Set the index to N, strip the space, and you're done.

    CategoryIMAGEmake

    Inputs (2)

    NameTypeDefaultDescription
    imagelistSTRING
    selected_image_indexINT11–9900

    Outputs (1)

    NameTypeDescription
    image_nameSTRING