获取图像丨名称
Recover the original filename of the image in your pipeline
- image
- image_name
The image in your graph came from somewhere, and that somewhere had a filename. QING_GetImageName's whole trick is to find it: feed it any IMAGE, and it walks your graph backwards through the wires, hunting for the loader that produced it, and hands you the original name as a string. It's the "what did we call this file" memory that plain image tensors throw away.
How it works
The mechanism is clever and worth knowing, because it explains the node's limits. It reads ComfyUI's internal prompt structure for the current run, starts at this node's position, and traces upstream through the graph - up to 32 hops - looking at each upstream node's inputs for a filename-bearing field (image, filename, file, path, image_path). The first one it finds becomes the answer. If it walks the whole chain and finds nothing, it falls back to image.png.
Two inputs: image (the IMAGE whose name you want) and include_extension (boolean, default false - strip or keep the .png). One output: image_name (STRING). The hidden prompt/unique_id inputs do the graph-tracing; you never touch them.
Where you'd reach for it
The natural partner is QING_SaveImage in the same pack. SaveImage will happily use an upstream filename for its output name - but only if you hand it that name, and GetImageName is how you extract it for use elsewhere (naming a sidecar file, a metadata record, a log line, or a folder structure). It's also just a great debugging node: drop it into a pipeline and you instantly know which source image a branch is actually operating on - useful in loops where ten images pass through the same nodes.
Because it reads the trace rather than any pixel data, it works regardless of what happened to the pixels in between. Crop, resize, whatever - the name survives, as long as the trace does.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Restart ComfyUI after. It ships in the same pack as everything else QING; no special dependencies. ComfyUI Manager: search "ComfyUI-QING." (And the README's GAOSHI-QING clone-URL typo - the repo is GAO-SHIQING/ComfyUI-QING.)
Things to know
The fallback is the honest limitation: if the image was generated in this workflow rather than loaded from a file (a KSampler output, say), there's no upstream filename to find, and you get image.png. If you're saving generated output and want a real name, give QING_SaveImage a new_name directly instead of expecting GetImageName to invent one. Also: a node like ImageBatch or a merge in between can break the trace - if it returns the fallback unexpectedly, check whether something on the path has no filename field. It's a heuristic, not magic, but for the common "loaded image → processed → save" case it's exactly right.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| include_extension | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image_name | STRING | — |