🍒MaxLength_ImageListSelector✔️最长图片列表选择
Keep the image list that came back longest
- 图片列表1
- 图片列表2
- 图片列表3
- 图片列表4
- 图片列表5
- 最长图片列表
Here's a workflow shape you've probably hit: you run the same image through several detection or cropping branches, and you want to keep whichever branch found the most stuff. MaxLength_ImageListSelector exists for exactly that - it takes up to five image lists and passes through the longest one.
It's a tiny node and it knows it. There are no settings, no sliders, no models. You feed it lists, it compares lengths, out comes the longest. The docstring spells out the intended use: "from multiple processing branches, select the branch that produced the most images." That's the whole pitch, and it's genuinely handy in two spots:
- Crop-and-detect pipelines. Run Split_Mask or a YOLO crop on a batch, and one branch might come back with three cutouts while another returns one. Feed both lists in, keep the three.
- Multi-model filtering. Two filters in parallel, each deciding what survives; you want the result that kept more images rather than writing a rule for which filter "should" win.
Inputs. The node is one of several in this pack with Chinese input names, so don't panic when you see them in the UI - they're just "Image List 1" through "Image List 5."
图片列表1and图片列表2(Image List 1, 2) - required. These are list inputs; wire in the list output of a node that returns multiple images.图片列表3–图片列表5- optional, same idea.
Output. 最长图片列表 (the longest image list) - an IMAGE list you can feed straight into a batch process, an Image List Splitter, or a Save node.
How it works. Each input is coerced to a list (a single image gets wrapped), lengths are compared, and the first list that ties for the max length wins. If every input is empty it returns a 1×1 placeholder image rather than an empty list - a deliberate guard so downstream nodes don't blow up, and one of those things that's nice until you see a 1×1 black pixel show up in your output and have to remember why.
Gotchas. Because it's a list-length comparison, it doesn't care what the images are - the longest list is just the longest list. If you want "the branch that found the most valid images," filter empties first (the pack's Transparent_Image_Filter is made for exactly that) and feed the result here. And remember the tie-break is first-come: if two branches return the same count, the one wired into the lower-numbered input wins.
Install. It ships in KimNodes (wjl0313's cherry-prefixed 🍒 toolbox). ComfyUI Manager → search "ComfyUI_KimNodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/wjl0313/ComfyUI_KimNodes
then restart. No dependencies worth mentioning beyond the pack itself - it's pure list arithmetic on PyTorch tensors.
Troubleshooting. If the output looks wrong, check what's actually on the wire: a node that claims to return a list but hands you a single batched tensor (shape [N, H, W, C]) still counts as one item here. Use a real list-producing node - the pack's Split_Mask, YOLO_Multi_Crop, or ComfyUI's native Image List nodes - before the selector, and it'll behave the way you expect.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| 图片列表1 | IMAGE | — | |
| 图片列表2 | IMAGE | — | |
| 图片列表3opt | IMAGE | — | |
| 图片列表4opt | IMAGE | — | |
| 图片列表5opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 最长图片列表 | IMAGE | — |