Load Images By Names
Load scene images by name from the output folder
- names
- image
- mask
- count
- image_path
LoadImagesByNames is the pack's image loader, and its superpower is that you address images by name, not by dragging files around. Given a list like ["milo", "luna"] and a folder, it finds the files with those stems - milo.png, luna.webp, whatever - and returns them as an IMAGE batch, in the order you asked. In the Story JSON Nodes pack (stepan-bogatorjov/comfy_scenes_json_node), the story JSON names characters and scenes, and this node is how those names become actual pixels for the rest of the graph.
The realistic reason you reach for it: your scene images land in output/ with predictable filenames, and a per-scene loop wants to pull "the picture for scene 3" without you hand-wiring a loader per scene. You drive it from the JSON or a text node, it resolves the paths, and it returns the batch plus a count and the resolved paths - so downstream nodes can see what actually loaded.
How it works
The names input is deliberately flexible: it accepts a real list, a JSON array string (["milo","luna"]), a Python-repr list with single quotes, or a comma/newline-separated string. It builds a case-insensitive index of filename stems in the folder, matches in input order, and loads each with EXIF orientation applied. Images of different sizes are resized (LANCZOS) to the first image's dimensions so they batch cleanly. Alpha channels become masks - inverted, so transparent pixels are 1 - and images without alpha get a zero mask. Missing names are skipped with a console note; if nothing matches at all, you get a 1×1 placeholder instead of a crash.
Inputs and outputs
- names - the list, in whatever string form. Force-input, so wire it from a JSON/text node.
- folder - relative to ComfyUI's
output/(or an absolute path). Empty meansoutput/itself. - image (IMAGE) - the batch.
- mask (MASK) - per-image alpha masks.
- count (INT) - how many actually loaded.
- image_path (STRING) - the resolved paths (as a list-carrying string).
Install
cd ComfyUI/custom_nodes
git clone https://github.com/stepan-bogatorjov/comfy_scenes_json_node
Restart ComfyUI (or install via Manager under "Story JSON Nodes"). No extra dependencies.
Troubleshooting
Three things bite people. First, the folder path: it's resolved relative to output/, so scenes means output/scenes, not a directory next to your workflow. Second, masks are alpha-inverted - if your transparency direction looks backwards, that's why; opaque pixels give 0 and transparent give 1, matching ComfyUI's mask convention where white is "affected". Third, the placeholder on no-match: count will be 0, and a silent 1×1 image flowing downstream can produce baffling "small image" errors later - check count before you trust the batch.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| names | * | — | |
| folder | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| count | INT | — |
| image_path | STRING | — |