Nodes/ComfyUI-YogurtNodes/Get Image Size (Yogurt Nodes)
ComfyUI Node

Get Image Size (Yogurt Nodes)

Nine outputs off one wire, and the quiet workhorse of adaptive workflows

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
Get Image Size (Yogurt Nodes)
  • image
  • image
  • batch_size
  • width
  • height
  • channels
  • longest_side
  • shortest_side
  • aspect_ratio
  • megapixels

You want a workflow that adapts to whatever image you drop into it - resize to match the source, generate at the right aspect ratio, feed dimensions into a prompt. To do any of that you need the image's dimensions as numbers inside the graph, and that's the whole job of Get Image Size (Yogurt Nodes). It takes one image and hands you nine outputs, starting with the size numbers you actually came for.

The trick that makes it genuinely useful is that it passes the image through on its own output while giving you the numbers. So you can stick it in the middle of a chain, grab width, height, batch_size and friends as you go, and never have to fork your image wire. Wire those ints into an ImageScale, a LatentFromBatch, or a String Format node building a prompt line like "a {width}px wide canvas" and you have a workflow that no longer cares what size image you feed it.

How it works

ComfyUI images are tensors shaped [batch, height, width, channels], and this node is basically just reading that shape. It pulls batch_size, height, width, and channels straight off the tensor, then does a little arithmetic on top: longest_side and shortest_side are the max and min of width/height, aspect_ratio is width divided by height, and megapixels is width × height divided by a million. Nothing is generated, nothing is resized - it's a pure information node, instant on even the biggest batches.

The outputs that matter

All nine come out of the one image input. The ones you'll actually reach for:

  • width / height - the raw dimensions as ints. These are what you feed into resize or latent nodes so everything downstream matches the source.
  • batch_size - how many frames/images are in the tensor. Useful when a video decode or batch pipeline hands you a count you need elsewhere.
  • aspect_ratio - handy for picking a generation resolution with the same proportions, or for logic that branches on portrait vs. landscape.
  • megapixels - surprisingly useful. The Image Scale To Total Pixels nodes in this same pack target a megapixel budget, so reading the current megapixels tells you whether an image is already at target.

The image passthrough, channels, longest_side, and shortest_side outputs round out the set - longest_side is nice for "is this above my tiling threshold" checks.

Installing it

It's part of ComfyUI-YogurtNodes, a ~150-node pack from yogurt7771 that covers image processing, LoRA ops, string/logic helpers, and a big set of paid API nodes. Install it with ComfyUI Manager (search "ComfyUI-YogurtNodes") or:

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

Restart ComfyUI and everything lands under "Yogurt Nodes". Requirements are light - numpy, pillow, requests - no models to download.

Where people get burned

Honestly, there isn't much to trip over. One thing: this reads the tensor's current shape, not the image file's original dimensions. If the image has already been resized or VAE-decoded by the time it reaches this node, you get the shape at that point in the graph - which is usually exactly what you want, but don't assume it's the source resolution. And if an input ever looks wrong, check whether something upstream changed the batch size; batch_size is the first number to glance at when a video chain misbehaves.

CategoryYogurtNodes/Image

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (9)

NameTypeDescription
imageIMAGE
batch_sizeINT
widthINT
heightINT
channelsINT
longest_sideINT
shortest_sideINT
aspect_ratioFLOAT
megapixelsFLOAT