ComfyUI Node

Load Images (Blaze)

Stuff a whole folder of images into one batch, fast

By nova452·Created 3 months ago·Updated 27 days ago· 509
Load Images (Blaze)
    • image
    • mask
    • count
    directory_path
    subfolder_depth0
    width1024
    height1024
    method
    cap0
    start_index0

    ComfyUI's built-in LoadImage loads one image at a time. That's fine for a single reference and actively painful the moment you're training a LoRA, testing 200 seed images, or feeding a character sheet into a reference encoder. LoadImagesBlaze from the Rebalance Pack is the folder-sized version: it loads a whole directory of images into a single batched tensor, resizes them all to a uniform size on the way in, and hands you a mask of any alpha channels along with it.

    The "Blaze" in the name isn't marketing fluff - it uses a thread pool to decode and resize in parallel (up to 8 workers), and it uses OpenCV's fast decoder when it's available. A folder that'd take a minute of single-threaded PIL churn becomes a few seconds.

    How it works

    Point it at a directory and it collects every .jpg, .jpeg, .png, .webp, or .tga inside, sorted alphabetically. subfolder_depth controls recursion: 0 is the folder itself, 1 adds immediate subfolders, N goes N levels deep, and -1 means unlimited. Then every image gets resized to your width × height (default 1024×1024, -1 means "keep original size" on that axis) using the method you pick:

    • crop - resize to cover the target, then crop the center. Loses edges, keeps the ratio. Best when every pixel of the target must be real image.
    • pad - resize to fit, then pad with the median edge color of the source. Keeps the whole image, adds bars. Best for training batches where you don't want to lose content.
    • stretch - distort to the exact size. Rarely what you want, but it's there.

    cap (0 = all) and start_index slice the folder, so you can page through a big set without loading everything at once.

    Outputs are image (the batch tensor), mask (a MASK built from each file's alpha channel, inverted to match ComfyUI's convention - 1.0 where there's no image), and count (how many files loaded, useful for driving a BatchCount or a loop). The mask is the subtle gem: load a folder of transparent PNGs and you get their alpha as a mask for free, which is exactly what a masked-inpainting or compositing pipeline wants.

    The inputs that matter

    • directory_path - the folder. Relative paths resolve against ComfyUI's base directory.
    • width / height - target size. -1 preserves that axis.
    • method - crop/pad/stretch.
    • cap / start_index - optional paging, off by default.
    • subfolder_depth - 0 to -1.

    Install

    Part of the Rebalance Pack. ComfyUI Manager: search "ComfyUI-Conditioning-Rebalance" (or "Rebalance Pack"). Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/nova452/ComfyUI-ConditioningKrea2Rebalance
    

    Restart afterwards. One optional dependency: it uses OpenCV (cv2) for speed and logs a warning if it's missing, falling back to slower PIL loading. If you load a lot of folders, pip install opencv-python into your ComfyUI environment and the warning disappears.

    Troubleshooting

    The classic failure is a FileNotFoundError - the node raises one if the directory doesn't exist or contains no images (after start_index/cap slicing), so check the path and the slice values. The less obvious one: because the batch tensor is built from the first image's dimensions, every output frame is forced to that size - if you mix resolutions you'll get the crop/pad/stretch result for all of them, never a variable-size batch. That's usually what you want for training, but it means mixed folders need a deliberate method. And on huge folders, cap is your friend for a quick look before committing to the full load.

    CategoryRebalance-Pack/utilities

    Inputs (7)

    NameTypeDefaultDescription
    directory_pathSTRING
    subfolder_depthINT0
    widthINT1024
    heightINT1024
    methodCOMBO3 options: crop, pad, stretch
    capoptINT0
    start_indexoptINT0

    Outputs (3)

    NameTypeDescription
    imageIMAGE
    maskMASK
    countINT