文件夹图像载入器
Load every PNG in a folder at runtime — no dropdown, no restart
- images
- count
ComfyUI's stock LoadImage has you pick a file from a dropdown that only shows your input folder - and it caches that list until you refresh. That's fine for a human clicking around. It's a wall if your workflow is a batch job that processes whatever landed in a folder since the last run. FolderImageLoaderNode (display name "Load Images from Folder") reads a directory at runtime: you give it a path, it grabs every .png in there, and hands you the images and their filenames as two lists. No refresh button, no dropdown, no restart.
It's the entry point of the whole ComfyForEach pack, which is built around the pattern of "folder per task, process each image one at a time." You'll almost always pair it with the pack's two selectors: index an image out of image_list, index its name out of image_name_list in lockstep, and you've got a per-file batch loop.
How it works
Mechanically it's honest, short Python. It joins root_path/task_id/suffix_path, checks the folder exists (and throws a clear ValueError if it doesn't), lists .png files sorted alphabetically, then for each one: opens with PIL, applies exif_transpose so phone photos aren't sideways, converts 16-bit mode 'I' images down to 8-bit range, converts to RGB, normalizes to 0–1 floats, and wraps each image in its own one-frame tensor.
That last part is the one thing to internalize. The node returns a Python list of tensors - one tensor per file, each shaped (1, H, W, 3) - not a single batched IMAGE. The outputs are named image_list and image_name_list on purpose. Don't plug image_list straight into a KSampler and wonder why the frontend frowns at you; index it first with IndexedImageSelectorNode.
Inputs that matter
Three strings, and honestly only one is interesting:
root_path- base directory, default empty. Set this to your images folder.task_id- the middle path segment (defaultabc123). This is where the "folder per task" idea lives: point one ComfyUI instance at a root, and each task's images live inroot/task_id/....suffix_path- optional extra subdirectory; the pack's pattern is leaving it blank.
Outputs: image_list (IMAGE, one tensor per file) and image_name_list (STRING, the filenames in the same order). The name list is your map back to source files after processing.
Install
ComfyUI Manager, search ComfyForEach, or:
cd ComfyUI/custom_nodes
git clone https://github.com/pupba/Comfy_ForEach
cd Comfy_ForEach
pip install -r requirements.txt
Restart and you're done. Dependencies are pillow, boto3, opencv-python-headless, numpy, and torch (ComfyUI's own). No model files to fetch. The README's instructions for patching ComfyUI's execution.py etc. are only needed for the AWS EventBridge error reporting - skip them for plain batch loading.
Where people get burned
- Folder not found - it raises immediately with the full path in the message. Double-check your
root_pathis relative to where you launched ComfyUI. - PNG only - it silently ignores
.jpg,.webp, anything not ending in.png. Feed it a mixed folder and it just sees fewer files. A lot of users hit this and assume the node is broken. - The list-vs-batch thing again: if you're coming from a pack like rgthree or Impact Pack that flattens lists for you, remember this one expects you to do the indexing yourself. That's the pack's model, and it's fine - it just means the selector nodes aren't optional.
This is a no-frills utility with real value for scripted, headless runs - the kind of thing the same author built the Rabbit-Hole pipeline tool around. For an interactive workflow you may not need it. For "process whatever showed up in this folder," it's exactly right.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | 包含图片文件的文件夹路径。支持绝对路径,或相对于ComfyUI根目录的相对路径。仅读取本目录下的图片,不会检索子目录。Folder path containing image files. Supports absolute paths or relative paths to the ComfyUI root directory. Only reads images from this directory, not subdirectories. | |
| size_mode | COMBO | resize_to_first | 图片尺寸处理方式:resize_to_first — 所有图片统一缩放至第一张图的宽高;filter_same_size — 仅加载与第一张图尺寸完全相同的图片,尺寸不同的会被跳过并在控制台提示。Size mode: resize_to_first — resize all images to the first image's dimensions; filter_same_size — only load images exactly matching the first image's dimensions. |
| skip_first_n | INT | 0 | 跳过文件夹排序靠前的N张图片。默认0表示不跳过。Skip the first N images in the folder. Default 0 means no skip. |
| load_count | INT | 0 | 最多载入的图片数量。设置为0表示不限制,载入全部符合条件的图片。如果该值大于文件夹内实际图片数量,则全量输出。Maximum number of images to load. Set to 0 for unlimited (loads all matching images). If the value exceeds the actual count, all images are output. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| count | INT | — |