Load Image
Load a folder of images as a batch — and get their filenames out
- get_image_size
- image
- mask
- filename
ComfyUI's built-in Load Image is a widget-based picker: click a thumbnail, load one file, repeat. It's fine until you need to load a directory of frames as a batch - for video work, dataset prep, or batch processing - and then it's actively in the way. Load Image from the 1hewNodes pack takes a plain path string, loads a single file or a whole folder, and hands back an image batch, a matching mask batch, and the filenames themselves.
The filename output is the sleeper feature. Stock loaders give you a filename too, but this one returns it as a string list that stays aligned with your batch - so when you save the results later you can re-attach each frame's original name. That turns out to be everything for folder round-trips.
How it works
- file - a path to an image file or a directory. Absolute paths work; relative ones resolve against ComfyUI's input directory.
- index - when loading a single image from a folder, pick by position (0-based, supports negative indices via modulo, so
-1is the last file). - all - the big one.
trueloads every matched image into one batch. - include_subdir - recurse into subfolders when
fileis a directory. - get_image_size - an optional reference image. When provided, everything is center-cropped and resized to its size, so a mixed-resolution folder becomes a uniform batch. Without it, the first loaded image sets the reference size.
The mask output comes from each image's alpha/transparency (following the ComfyUI convention where transparent = white mask), plus sidecar mask files if present - files like name_mask.png or name.mask.webp next to the image are picked up and merged. Supported formats: jpg, png, webp, gif, bmp, tiff.
Outputs: image, mask, and filename (a list of filename stems).
Install
Part of ComfyUI-1hewNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI. No models, no downloads.
Where it fits
The pattern it was built for: decode a video to frames → load that folder as a batch → process → save with original filenames. Or the dataset prep loop: point it at a folder, unify to a size with a reference image, batch-process, and re-save with the same names. The filename list is what makes the round-trip lossless.
Common issues
- Everything got cropped - size unification is center-crop + resize to the reference (or first) image's aspect ratio. A folder full of different aspect ratios gets its edges trimmed to match. Use
fit=pad-style logic elsewhere if you must preserve full content. - Mask is "backwards" - the alpha-derived mask is
1 - alpha, i.e. transparent pixels become white in the mask. That's the ComfyUI convention (white = mask selected = transparent), and it's the same convention the built-in loader uses. Not a bug. - Path not found - relative paths resolve against the input directory, not the workflow folder. When in doubt, use an absolute path.
It's the rare "better Load Image" that earns its place: folder batch loading plus aligned filenames, and it doesn't try to be anything fancier.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| file | STRING | — | |
| index | INT | 0-8192–8192 | — |
| include_subdir | BOOLEAN | true | — |
| all | BOOLEAN | false | — |
| get_image_sizeopt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| filename | STRING | — |