Nodes/comfyui-moonpack/Dimension From Image
ComfyUI Node

Dimension From Image

Read an image's size so the rest of the graph can adapt

By moonwhaler·Created about a year ago·Updated 12 days ago· 16
Dimension From Image
  • image
  • width
  • height
  • batch_size

This is the sort of node you'll use constantly and never think about, which is exactly what a utility node should be. Dimension From Image looks at an IMAGE tensor and hands you three integers: width, height, and batch_size. That's it. No math, no presets, no opinions - it reads the shape and reports back.

Why is that useful? Because once the size is a value in the graph instead of a number you typed, your workflow can adapt to whatever image you feed it. Load a 1024x1024 PNG today and a 512x768 crop tomorrow, and the downstream nodes follow along instead of forcing you to edit widgets by hand.

The inputs and outputs that matter

One required input, image - a standard image tensor shaped [B, H, W, C] (batch, height, width, channels). Everything ComfyUI loads produces this, so wire it in from Load Image, an upscaler, a VAE decode, anywhere.

Three outputs, all integers:

  • width and height - the image's dimensions in pixels. Feed these into EmptyLatentImage, into resolution math, or into a save-path string.
  • batch_size - the frame count for an image sequence. This is the one people forget about. If you're feeding video frames or an image batch through, batch_size tells you how many images you actually have. Video loops and frame-based workflows depend on that number.

How you'll actually wire it

The boring-but-common loop: Load Image → Dimension From Image → feed width/height into a latent setup so the graph always generates at the source's resolution. The slightly cleverer version: chain it into a proportional dimension node or a resolution calculator so an upscale pass targets a consistent megapixel budget regardless of the input size - the kind of thing the KB's upscaling guidance pushes hard, because generating or upscaling at a model's native resolution beats guessing.

There's genuinely nothing to tune here, which is the point. If you already have a different "get image size" node you're happy with, you don't need to switch - this one exists so MoonPack's dimension nodes can read from an actual image instead of relying on widgets.

Installing it

It's part of the MoonPack pack, installed the usual way:

cd ComfyUI/custom_nodes
git clone https://github.com/moonwhaler/comfyui-moonpack.git

Restart ComfyUI after cloning, or just search MoonPack in ComfyUI Manager. The node lives under MoonPack/image. No models to download, no heavy dependencies - MoonPack deliberately ships with zero third-party Python requirements beyond what ComfyUI already has.

Bottom line

A one-input, three-integer node isn't exciting, and it isn't meant to be. But once you start building workflows that react to whatever image they're given, Dimension From Image is one of those nodes you reach for without thinking - and batch_size on the output saves you from counting frames by hand.

CategoryMoonPack/image

Inputs (1)

NameTypeDefaultDescription
imageIMAGEImage tensor (shape [B, H, W, C]).

Outputs (3)

NameTypeDescription
widthINT
heightINT
batch_sizeINT