ZML_从路径加载图像
Load images from a real folder, not the input drawer
- 图像列表
- 文本块
- Name
- 图像路径
- 图像数量
ComfyUI's stock loader is stuck inside its input folder. If your images live in a real directory on disk - a photo dump, a dataset, a folder of WIPs - you either copy them into ComfyUI or you write a path-based loader. ZML_LoadImageFromPath is the ZML pack's version, and the README history shows it's one of the pack's most-worked-on nodes: fixed index, random index, sequential, "load everything," text block reading, and filename normalization all in one.
The 文件夹路径 (folder path) is the only thing you must set - an absolute path, or a path relative to the ComfyUI root. Everything else is the interesting part. 索引模式 (index mode) decides which image you get:
固定索引(fixed index) - uses图像索引, a plain integer. Set it to 3, get the third image. Deterministic, boring, exactly right for "I know which file I want."随机索引(random) - picks one at random each run. The README's phrase for this is 抽卡 (gacha). Great for shuffling through a folder to find something you forgot you had.顺序(sequential) - steps through the folder one image per run, tracked per-node in a counter JSON file in the pack's folder. This is the "feed images one at a time into a generation loop" mode.全部(all) - returns every image in the folder as a batch.
Outputs: 图像列表 (the images, as a list), 文本块 (the ZML text block from the file, if 读取文本块 is enabled - the pack's own save format), Name (the normalized filename, same #-# normalization rules as ZML_LoadImage), 图像路径 (full paths of what was loaded), and 图像数量 (how many files the folder contains). The path output is a sleeper feature: you can wire it into other ZML nodes that want a folder path, or use the count for loops.
The mechanism is nothing fancy - it scans the folder with Path.iterdir(), filters by supported extensions (png/jpg/gif/bmp/tiff/webp), sorts, and loads with Pillow, honoring EXIF orientation. It also resets its sequential counters on startup, which is a small but important detail: you don't get stuck mid-folder forever after a restart.
The traps are the real-world ones. Mixed resolutions come back as a list, and downstream nodes that want a single batch will complain - normalize first if that's your plan. The random/sequential modes return float("NaN") for IS_CHANGED, so they force a rerun every time, which is correct but means this node is always "dirty" in the graph - don't put expensive stuff upstream of it. And a nonexistent path silently returns empty lists plus a 0 count rather than an error, so "no images found" looks like a blank output until you check the count.
Install once for the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
or Manager search "ComfyUI-ZML-Image", then restart. It lives under ZML 图像 → 图像. No heavy dependencies for this one - just Pillow, which you already have.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| 文件夹路径 | STRING | — | |
| 索引模式 | COMBO | 固定索引 | 4 options: 固定索引, 随机索引, 顺序, 全部 |
| 图像索引 | INT | 0 | — |
| 正规化 | COMBO | 正规 | 4 options: 禁用, 仅名称, 正规, 反向 |
| 读取文本块 | COMBO | 禁用 | 2 options: 启用, 禁用 |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| 图像列表 | IMAGE | — |
| 文本块 | STRING | — |
| Name | STRING | — |
| 图像路径 | STRING | — |
| 图像数量 | INT | — |