Nodes/ComfyUI-ZhiHui/📁 智绘_文件夹加载
ComfyUI Node

📁 智绘_文件夹加载

The whole folder, normalized into one batch — with pad/crop/stretch rules

By zhuyungen·Created 8 months ago·Updated 4 months ago· 0
📁 智绘_文件夹加载
    • 🖼️ 图像批次
    • 🔢 数量
    • 📂 文件名列表
    ◄📂 文件夹路径►
    ◄🔢 加载数量0►
    ◄🏁 起始索引0►
    ◄🔄 排序方式文件名升序 (A-Z)►
    ◄📐 统一尺寸规则统一为首图尺寸►
    ◄↔️ 指定宽度512►
    ◄↕️ 指定高度512►
    ◄📏 限制最长边0►
    ◄🛠️ 适配模式保持比例-填充黑边►
    ◄🎨 填充颜色#000000►

    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.

    Category智绘灵箱

    Inputs (10)

    NameTypeDefaultDescription
    📂 文件夹路径STRING图片所在的文件夹路径
    🔢 加载数量INT00–10000限制加载图片的数量,0表示加载所有
    🏁 起始索引INT00–10000跳过前N张图片
    🔄 排序方式COMBO文件名升序 (A-Z)5 options: 文件名升序 (A-Z), 文件名降序 (Z-A), 日期 (最新在前), 日期 (最旧在前), 随机
    📐 统一尺寸规则COMBO统一为首图尺寸2 options: 统一为首图尺寸, 指定固定尺寸
    ↔️ 指定宽度INT51264–8192仅在选择'指定固定尺寸'时生效
    ↕️ 指定高度INT51264–8192仅在选择'指定固定尺寸'时生效
    📏 限制最长边INT00–16384预处理:将图片最长边限制在指定像素内(0不限制)。对'统一为首图尺寸'模式有效,可减小显存占用
    🛠️ 适配模式COMBO保持比例-填充黑边当图片尺寸与目标批次尺寸不一致时的处理方式
    🎨 填充颜色STRING#000000填充黑边时的背景颜色(Hex格式)

    Outputs (3)

    NameTypeDescription
    🖼️ 图像批次IMAGE—
    🔢 数量INT—
    📂 文件名列表STRING—