📁 智绘_文件夹加载
The whole folder, normalized into one batch — with pad/crop/stretch rules
- 🖼️ 图像批次
- 🔢 数量
- 📂 文件名列表
Loading a folder of images into ComfyUI usually means fighting two problems at once: mixed resolutions that torch can't stack, and a wall of files you only want a slice of. ZH_LoadFolder ("📁 智绘_文件夹加载") solves both in one node - it reads a folder, lets you sort and slice it, then force-normalizes every image to a single size so the result stacks into a clean batch.
It's part of ComfyUI-ZhiHui, a small Chinese-language utility pack. It arrived as part of the Dapao-Toolbox integration (the pack's own guide is explicit about the lineage), and it's one of the more genuinely useful nodes in the batch - if you've ever prepped a dataset or fed a folder into an upscaler, this is the shape of tool you wanted.
How it works
Straightforward file plumbing under the hood. It lists the folder, filters to the usual raster formats (jpg, png, bmp, webp, tiff, gif), sorts by your choice of rule, slices by start index and load count, then computes a target resolution and resizes every image to it before stacking.
The size handling is where this earns its keep. Two rules for the target:
- 统一为首图尺寸 - everything gets resized to the first image's dimensions. Turn on 📏 限制最长边 and the first image's size is first scaled down to fit that cap, which keeps enormous scans from blowing up your VRAM.
- 指定固定尺寸 - you set width/height directly (64–8192).
Then the 🛠️ 适配模式 decides what happens to images that don't match the target: 保持比例-填充黑边 (aspect-fit with letterbox, default), 保持比例-居中裁剪 (aspect-fill, center-crop), or 拉伸 (plain stretch, distorts). Pad color is configurable via 🎨 填充颜色 (hex, default #000000). The default pair - first-image size + black padding - is the sane one for almost everything.
The inputs and outputs that matter
The three you'll actually touch: 📂 文件夹路径 (raw OS path - this is not a virtual input/ path; it's absolute), 🔢 加载数量 (0 = load everything), and 🔄 排序方式 (name asc/desc, date newest/oldest, random). The rest are normalization knobs for when you need them.
Outputs: 🖼️ 图像批次 (IMAGE, the stacked batch), 🔢 数量 (INT), and 📂 文件名列表 (STRING - a list of the loaded filenames, handy for downstream tracking).
Install
cd ComfyUI/custom_nodes
git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git
Restart ComfyUI. This node needs only the pack's base deps (torch, numpy, Pillow) - no models, no heavy installs. ComfyUI Manager search "ComfyUI-ZhiHui" works too.
Where people get burned
Three gotchas. First, the path is a real filesystem path - if you type my_images expecting the ComfyUI input/ folder, it won't resolve; give it the full path. Second, the default "first image size" mode means the batch's resolution is decided by whatever file sorts first, so shuffle your sort order if you want the dominant size. Third, if the folder ends up with zero loadable files it returns a 1×1 black image and count 0 rather than erroring - that keeps the graph alive but silently feeds garbage downstream, so check the count output before trusting the batch.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| 📂 文件夹路径 | STRING | 图片所在的文件夹路径 | |
| 🔢 加载数量 | INT | 00–10000 | 限制加载图片的数量,0表示加载所有 |
| 🏁 起始索引 | INT | 00–10000 | 跳过前N张图片 |
| 🔄 排序方式 | COMBO | 文件名升序 (A-Z) | 5 options: 文件名升序 (A-Z), 文件名降序 (Z-A), 日期 (最新在前), 日期 (最旧在前), 随机 |
| 📐 统一尺寸规则 | COMBO | 统一为首图尺寸 | 2 options: 统一为首图尺寸, 指定固定尺寸 |
| ↔️ 指定宽度 | INT | 51264–8192 | 仅在选择'指定固定尺寸'时生效 |
| ↕️ 指定高度 | INT | 51264–8192 | 仅在选择'指定固定尺寸'时生效 |
| 📏 限制最长边 | INT | 00–16384 | 预处理:将图片最长边限制在指定像素内(0不限制)。对'统一为首图尺寸'模式有效,可减小显存占用 |
| 🛠️ 适配模式 | COMBO | 保持比例-填充黑边 | 当图片尺寸与目标批次尺寸不一致时的处理方式 |
| 🎨 填充颜色 | STRING | #000000 | 填充黑边时的背景颜色(Hex格式) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 🖼️ 图像批次 | IMAGE | — |
| 🔢 数量 | INT | — |
| 📂 文件名列表 | STRING | — |