Nodes/APW_Nodes/Image List Filter
ComfyUI Node

Image List Filter

Drop the too-small images from a batch before they waste a pass

By alessandroperilli·Created about a year ago·Updated 12 months ago· 4
Image List Filter
  • images
  • fallback_image
  • images
  • removed_indices
width_min0
height_min0

If you've ever batch-loaded a folder of images into ComfyUI and realized half of them are 512px thumbnails you'd rather not feed to a 2x upscaler, Image List Filter is the node you were missing. It takes an image list, throws out anything below a minimum width or height, and hands back a clean list. Dead simple, and it's one of those "oh, that exists" quality-of-life wins.

It's part of APW_Nodes, the utility suite Alessandro Perilli carved out of his "AP Workflows for ComfyUI". The code is a trimmed-down port of Kijai's Image Batch Filter from KJNodes - the README credits it - so if you've used that, the behavior will feel familiar, just smaller and with one extra trick.

How it works

The node runs with INPUT_IS_LIST = True, so it genuinely receives a list of images rather than a batch tensor. For each image it looks at the (B, H, W, C) shape, compares width and height against your thresholds, and keeps or drops it. The removed indices come back as a comma-joined string, which is handy for debugging - you can see exactly which slots in your batch got cut.

The interesting bit is the fallback. If every image gets filtered out, an optional fallback_image you provide gets emitted as a single-element list instead, so downstream nodes never choke on an empty batch. The fallback is normalized on the way in (uint8 → float32 0-1, with a batch dimension forced on), which is exactly the kind of thing that silently breaks previews and PIL consumers if you skip it.

The inputs that matter

  • images - the list to filter (required).
  • width_min / height_min - integers, default 0. 0 means no limit for that dimension. And here's the off-by-one that'll trip you: a value of N actually drops anything ≤ N, not < N. Set width_min: 512 and a 512px image gets removed. To keep everything at or above 512, set 511.
  • fallback_image - optional single image used if nothing survives the filter.

Wiring it up

Output images feeds straight into whatever consumes an image list - a batch upscaler, an img2img pass, a captioning loop. Use the removed_indices string if you want to log or branch on what got dropped. A natural pattern: load a directory with something like a folder/load batch node, filter by your working resolution, and only then spend compute on the pass. When you're feeding an upscaler, that's the difference between wasting a generation on a thumbnail and not.

Installing it

Same pack, same drill:

cd ComfyUI/custom_nodes
git clone https://github.com/alessandroperilli/apw_nodes

Restart ComfyUI, or search "APW Nodes" in ComfyUI Manager. No extra Python dependencies, no model files. The repo is archived - the author's moved on to OCS_Nodes - but it installs and runs unchanged.

Where people get burned

The threshold off-by-one above is the main one; "0 = no limit" is the second. People set width_min: 0 thinking it means "keep everything tiny" and instead get "no width filtering," which is usually what they wanted anyway. And don't forget the fallback: if you're filtering a list that can legitimately be entirely below your threshold, an empty output list will break whatever's downstream unless you wire in a fallback_image. The node can't save you from yourself there - that's what the optional input is for.

CategoryAPW Nodes

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
width_minINT0
height_minINT0
fallback_imageoptIMAGE

Outputs (2)

NameTypeDescription
imagesIMAGE
removed_indicesSTRING