Validate Image Shape
Check two batches match before the cat() blows up
- image_a
- image_b
- image
- valid
Validate Image Shape is a guardrail disguised as a node. It takes two image batches and tells you - with an actual boolean, not a crash - whether they share the same pixel dimensions. It exists because ComfyUI will happily let you pipe mismatched images into a concat or a batch join, and then explode at the last possible moment.
You know the failure: everything renders, the graph is mid-queue, and suddenly RuntimeError: Sizes of tensors must match. That's the moment this node is designed to prevent. You put it in front of anything that assumes matching shapes, check its valid output, and route accordingly.
How it works
The comparison is deliberately narrow. It compares image_a.shape[1:] against image_b.shape[1:] - that's height, width, and channels for each batch, ignoring the batch count itself. Two batches of the same H/W/C are "valid" even if one has 3 frames and the other has 7; the node doesn't care how many images, only that they'd actually stack together.
When they match, it returns (image_a, True) - it passes the first batch through unchanged. When they don't, it returns (None, False).
Inputs:
image_a(IMAGE) - "First image batch to validate."image_b(IMAGE) - "Second image batch to validate against the first."
Outputs:
image(IMAGE) - a pass-through ofimage_a, or None if invalid.valid(BOOLEAN) - the verdict.
Where you'd reach for it
- In front of Append Image Batch or Join Image Batch. They concatenate; if the inputs mismatch, they error. Check
validfirst and you fail gracefully instead. - Mixed-resolution pipelines. VAE Decode output can vary in size if latent tensors get resized along the way; this is the cheap way to catch it.
- Routing. Wire
validinto a Conditional Pass Through or Switch Any to send mismatched batches down a fix-up branch (a resize) and matching ones straight through.
Worth noting: it validates, it doesn't fix. If the check fails you still have to do something about it - that's what the resize/pad/crop modes on Join Image Batch are for.
Installation
Another node from Vantage Nodes. Install the pack once via ComfyUI Manager ("Vantage Nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/vantagewithai/Vantage-Nodes.git
pip install -r requirements.txt
Restart ComfyUI. No model downloads needed for the image utilities.
Troubleshooting
validis false and you expected true: check the actual pixel dimensions, not the batch counts. The node ignores batch size by design.- Graph still crashes after the check: remember the
imageoutput is justimage_apassed through - if you wired the wrong side, or a node downstream still receives a mismatched batch, no check can save you. Gate the path withvalidfirst.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | First image batch to validate. | |
| image_b | IMAGE | Second image batch to validate against the first. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| valid | BOOLEAN | — |