Image Batch to Images
Staple a folder of images into one fixed-size batch tensor
- image_batch
- fill_color
- image
- alpha
ImageBatchtoImages is the sibling of ImageBatchtoImageList with a different goal: instead of unpacking a batch into separate tensors, it folds a folder of images into a single stacked IMAGE batch - all forced to one canvas size. Feed it the pack's image_batch type (a list of file paths from Load Image Batch), tell it your target dimensions, and out comes one tensor with every image resized, cropped, or padded to fit.
That uniformity is the whole point. Samplers, ControlNet preprocessors, and video pipelines choke when a batch has mixed resolutions - ComfyUI wants a single (B, H, W, C) tensor. This node guarantees it: same size, same color treatment, every frame.
How it works
It iterates the paths, EXIF-transposes and loads each as RGBA, then forces it to width×height using the mode you pick:
- crop (center) -
ImageOps.fit, center-crops the excess. - resize (stretch) - plain resize; distorts aspect ratio.
- pad (fill) - fits inside, pads with your
fill_color. - pad (edge) - fits inside, pads by stretching the edge pixels (edge replication), which looks much better than flat color for photo-like input.
Interpolation is nearest, bilinear, bicubic, or lanczos. The output image is flattened to RGB over the fill color; the alpha output is the inverted alpha mask (white = transparent), which you can use downstream to composite or to tell the model where the "real" pixels are. Batch count comes straight from the number of files.
Inputs and outputs
image_batch(image_batch) - file paths from Load Image Batch.width/height(INT, default 512×512) - the forced canvas.interpolation- nearest / bilinear / bicubic / lanczos.mothed- crop (center) / resize (stretch) / pad (fill) / pad (edge).fill_color(COLOR_CODE, default#000000) - the pad color.
Two outputs: image (IMAGE, single stacked tensor) and alpha (MASK).
Installing it
Part of ComfyUI-lhyNodes:
- ComfyUI Manager → search
lhyNodes→ Install, restart. - Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/lihaoyun6/ComfyUI-lhyNodes.git
python -m pip install -r ComfyUI-lhyNodes/requirements.txt
Restart ComfyUI.
Where people get burned
The field is spelled mothed - not a typo in your brief, that's the actual parameter name, so a template referencing method won't match. The bigger trap is resize (stretch): it's the default-pill mode people pick when they just want "make it fit," and it silently squashes aspect ratios - for faces that's a recognizable kind of wrong. And remember the mask comes out inverted (white = transparent), which trips up anyone used to drawing masks in the editor. Beyond that, this is the workhorse: load a folder, get a clean batch, feed the model. That's the whole loop.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image_batch | image_batch | — | |
| width | INT | 512 | — |
| height | INT | 512 | — |
| interpolation | COMBO | 4 options: nearest, bilinear, bicubic, lanczos | |
| mothed | COMBO | 4 options: crop (center), resize (stretch), pad (fill), pad (edge) | |
| fill_color | COLOR_CODE | #000000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| alpha | MASK | — |