ComfyUI Node

Image Shape

Read a tensor like a spec sheet — Image Shape reports batch, width, height, and channels

By yanhuifair·Created 2 years ago·Updated 3 months ago· 2
Image Shape
  • images
  • batch
  • width
  • height
  • channel

Every ComfyUI image is secretly a tensor with a shape - [batch, height, width, channels] - and most of the time you don't need to know that. But the moment your workflow is doing conditional logic on image dimensions, or you're debugging why a batch operation is misbehaving, you need to see the numbers. Image Shape is the node that reads them off and hands them to you as four clean integers.

The mechanism is a shape read, straight from the source: images.shape is unpacked as batch, height, width, and channel in that order, and each value is emitted on its own output. There's no computation beyond that - it's the tensor equivalent of reading the label on a box. The one quirk to remember is the order: the node's outputs are named batch, width, height, channel, which rearranges the raw [B, H, W, C] layout into width-before-height on the way out. Feed the outputs into anything that expects width then height and you're aligned.

The single input:

  • images - any image batch.

The outputs:

  • batch - number of images in the batch.
  • width - width in pixels.
  • height - height in pixels.
  • channel - channel count (3 for RGB, 4 for RGBA).

Where it fits: this is the diagnostic sibling of the pack's Image Size node, which reports width, height, max/min side, and aspect ratio. Image Shape is the one you reach for when the batch count or the channel count is the thing in question - checking that a folder loader actually returned all 24 frames, confirming a node didn't secretly add an alpha channel, or feeding dimensions into a branch of logic that needs to react to image size. In the KB's node-plumbing taxonomy it's a diagnostics node: it exists to make the graph's state legible to the graph itself.

A natural pairing: wire Image Shape's width and height into an If or comparison chain so the workflow behaves differently for portrait versus landscape input, or use the batch count to gate a loop. Since these come out as typed integers, anything that eats an INT can read them.

Honest notes: it reports the current shape of whatever tensor is wired in, which after a resize or a VAE encode reflects the post-processing state, not your original input - that's usually exactly what you want for debugging, but don't confuse it with metadata. And there's no error handling for malformed tensors; feed it a proper image and it just works.

Install is the standard pack path: ComfyUI Manager → search ComfyUI-FairLab → install → restart:

cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt

Restart, search "Image Shape" or "tensor shape". No models, no dependencies - it's four integers read off a tensor.

CategoryFair/image

Inputs (1)

NameTypeDefaultDescription
imagesIMAGE

Outputs (4)

NameTypeDescription
batchINT
widthINT
heightINT
channelINT