Nodes/ComfyUI-XJNodes/Image List Filter
ComfyUI Node

Image List Filter

Strip the blank frames out of your image list automatically

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Image List Filter
  • images
  • images
  • removed_indices
empty_color0, 0, 0
empty_threshold0.01

Every so often a workflow produces a batch that's full of near-empty frames - black placeholders from an upscaler, failed crops, blank tiles from a folder with mixed content. Feeding those downstream wastes compute and pollutes results. XJImageListFilter is the pack's answer: it scans an image list, drops anything that's essentially a solid color, and tells you which indices it removed.

The node description keeps it to a single line - "Removes empty images from a list" - but the mechanism is a bit more flexible than that, because you get to say what "empty" means. It's part of the ComfyUI-XJNodes image toolkit, and it pairs naturally with the pack's XJLoadImagesFromDirBatch: load a folder, filter out the duds, keep the real content.

How it works

Each image in the list is compared against a target color, and if it's close enough to that color, it's dropped. The two knobs define "close enough":

  • empty_color (STRING, default "0, 0, 0") - the color treated as "empty," as comma-separated RGB. Black is the default because black placeholders are the usual offender; use "255, 255, 255" for white-background duds.
  • empty_threshold (FLOAT, default 0.01, 0–1) - the mean per-pixel difference from that color allowed before the image counts as not empty. Raise it if genuine near-black content is being wrongly nuked; lower it toward 0 to only drop truly solid frames.

Internally it computes the mean absolute difference between the image and the color across all pixels, and any image whose mean difference is at or below the threshold gets filtered out. That makes it robust to minor noise - a solid black tile with a hair of compression noise still fails the test and gets removed.

Outputs are images (the surviving list) and removed_indices - a comma-separated string of the positions that were dropped, which is surprisingly handy for debugging or for building a "what got thrown away" report.

Installing it

Part of ComfyUI-XJNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes

then restart ComfyUI (or ComfyUI Manager → ComfyUI-XJNodes). No models, no dependencies.

Common issues

The threshold is where people misjudge. At 0.01 (the default), anything with real content - even a dim, mostly-black image with some texture - survives; if your "empty" frames have visible noise, you may need to raise the threshold so they're recognized as empty. And remember empty_color is parsed as a string, so format it exactly like the default (R, G, B) or the parse fails. It's a small, single-purpose node, and those two knobs are genuinely all there is to tune.

CategoryXJNodes/image

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
empty_colorSTRING0, 0, 0
empty_thresholdFLOAT0.010–1

Outputs (2)

NameTypeDescription
imagesIMAGE
removed_indicesSTRING