ComfyUI Node

If Image Valid

The image fallback switch for looping workflows

By Fictiverse·Created 3 years ago·Updated 17 days ago· 27
If Image Valid
  • if_Valid
  • else_Image
  • IMAGE

If Image Valid is a small routing node with two optional image inputs and one image output. If the first input (if_Valid) has something connected and non-empty, that image passes through. Otherwise the second input (else_Image) is returned. If neither is present, you get a tiny black placeholder image so the graph doesn't outright break.

The use case is the semi-automated workflow - the kind where a node might legitimately produce nothing. Think of a loop, a queue-triggered sequence, or a workflow that loads an image from a file that might not exist yet, or runs a detection pass that can fail. ComfyUI generally hates None values flowing through wires - most nodes will choke on them. This node is the "or else" branch that keeps a fallback image in the graph so the pipeline stays alive instead of dying on an empty socket.

How it works

The logic is dead simple: if_Valid wins if it's not None, otherwise else_Image, otherwise a built-in fallback. Two honest caveats about what "valid" means here:

  • It checks "is this something" - i.e. not None - not "is this a good image." A broken or all-black image that's still a tensor counts as valid and passes through. If you need actual content validation (brightness, blankness), this isn't that node.
  • ComfyUI doesn't normally push None through wires, so in practice if_Valid being empty usually means "nothing connected this run" - which is exactly when the fallback kicks in.

The fallback image is worth knowing about: it's a 32×32 black square. If it ever makes it to a preview or a sampler, you'll see a tiny black blob. That's a feature - it's unmistakably a placeholder, so you'll notice your fallback logic fired instead of silently processing a wrong image. For anything real, always connect your own else_Image; treat the built-in black square as a tripwire, not a feature.

Inputs and outputs

Both inputs are optional:

  • if_Valid (IMAGE) - preferred source.
  • else_Image (IMAGE) - fallback source.

Output:

  • IMAGE (IMAGE) - whichever input won, or the black placeholder.

Installing it

Ships in ComfyUI Fictiverse Nodes. ComfyUI Manager → search "ComfyUI Fictiverse Nodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Fictiverse/ComfyUI_Fictiverse

No dependencies beyond torch/numpy (already present), no models. Apache 2.0.

Common issues

Pack gotcha: ModuleNotFoundError: No module named 'custom_nodes.ComfyUI_Fictiverse' means the folder isn't named exactly ComfyUI_Fictiverse; rename and restart.

Node-specific: the biggest confusion is expecting real validation. It's a None-check, not a content-check - if the image that arrives is garbage-but-present, it's "valid" and gets passed along. And if you leave both inputs unwired thinking you'll get a nice fallback, the 32×32 black square is what you'll get; any real use should feed else_Image from a source that's guaranteed to exist. If you see black squares in your output, that's this node telling you your "if" source went empty.

CategoryFictiverse

Inputs (2)

NameTypeDefaultDescription
if_ValidoptIMAGE
else_ImageoptIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE