Flatten Image List
Glue your image sets into one clean tensor
- images
- masks
- images
- masks
ComfyUI has a habit of handing you images in sets - a list of tensors here, a batch of frames there - and a matching habit of not accepting those sets where you want to put them. Flatten Image List is the small fix: it takes multiple image sets and concatenates them into a single tensor, in order. It's from SineSwiper's LoadAnim-Adv pack, and it's the natural cleanup step after a multi-file load.
What it does
Two optional inputs, images and masks - each accepting multiple image/mask sets (ComfyUI runs it in list-input mode, so "multiple" just means wire in whatever list your loader emitted). Two outputs: images and masks, each the concatenation of everything that went in. "Concatenated in order" means the frames from the first set stay first; nothing gets shuffled.
The classic use: the directory loader with flatten_frames off gives you a list of per-file tensors. Some downstream nodes eat that list fine; many don't. Drop Flatten Image List between them and the list collapses into one flat [total_frames, height, width, channels] tensor - exactly what a sampler or a video model wants. The node's description says it plainly: it combines "multiple sets of images (eg: from a multi-file load node) into a single set of frames."
How it works
Nothing clever under the hood - it's torch.cat along the frame axis (dim 0) for whichever inputs you provided. Both inputs are optional, so you can flatten just images or just masks. If you only give it one side, it fabricates an empty tensor of the right shape for the other - the mask output becomes an empty [0, height, width, 1] tensor, for instance - so the downstream connection stays type-valid instead of vanishing.
When you'd reach for it
- After Load Images/Videos From Directory with
flatten_framesoff, to make a single combined clip. - To merge two or more separately-loaded animations into one sequence - say, a loop and its tail.
- Any time a node complains it "doesn't accept a list of images."
Inputs and outputs
Inputs: images (IMAGE), masks (MASK) - both optional. Outputs: images (IMAGE), masks (MASK). That's the whole surface area. If both inputs are empty it prints a warning and returns (None, None) instead of crashing, which is friendly of it.
Installing
Part of ComfyUI-LoadAnim-Adv by SineSwiper. ComfyUI Manager → search "LoadAnim", or:
cd ComfyUI/custom_nodes
git clone https://github.com/SineSwiper/ComfyUI-LoadAnim-Adv.git
Restart ComfyUI. No models, no extra dependencies - just the pack's torch, numpy, Pillow.
Gotchas
- Only flatten what's meant to be flattened.
torch.catneeds matching shapes along every axis except the frame axis. If your sets have different resolutions - because you loaded some files at different sizes - the concatenation fails. Flatten after a consistent resize, not before. - It concatenates frames, it doesn't interleave or sort them. Order in equals order out.
- If you're loading a directory anyway, check
flatten_frameson the loader first - it does this for you in one step. Flatten Image List is for when the list came from somewhere that doesn't have that option, or you need to merge sets that weren't loaded together.
It's a tiny node with one job, and it does it without drama. In a video workflow, that's exactly the kind of boring reliability you want.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| imagesopt | IMAGE | Image set to combine. | |
| masksopt | MASK | Mask set to combine. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | The combined image set. |
| masks | MASK | The combined mask set. |