Nodes/ComfyUI Layer Style/LayerUtility: GetImageSize
ComfyUI Node Runs on cloud

LayerUtility: GetImageSize

GetImageSize — read an image's width and height into your graph

By chflame163·Created 3 years ago·Updated 8 days ago· 3,118
LayerUtility: GetImageSize
  • image
  • width
  • height
  • original_size

A tiny node that does exactly one thing: tells you how big an image is, as numbers you can actually wire into other nodes. Sounds trivial until you're three nodes deep into a graph and need an Empty Latent Image sized to match a photo someone just uploaded, or you're doing aspect-ratio math to decide whether to pad or crop. Eyeballing the size in the preview panel doesn't scale; this does.

How it works

There's no image processing happening here - it just reads the shape of the IMAGE tensor connected to it and reports it back. No resize, no resample, nothing lossy. If the image changes upstream (a resize node, a different upload), the numbers change with it, since GetImageSize reports whatever's actually flowing through the graph at that point, not some cached value from the original file. That live-reads-the-wire behavior is what makes it useful for conditional logic too - chain it before a branch that decides "pad to square" versus "crop to square" based on whatever the actual incoming dimensions turn out to be, rather than hardcoding an assumption about what size images will show up with.

The inputs and outputs that matter

There's exactly one input - image - and three outputs:

  • width and height (both INT) - plug these straight into an Empty Latent Image, a resize node's target dimensions, or a math node computing aspect ratio.
  • original_size (a BOX value) - a bundled width+height package. This is the one worth knowing about: several other nodes in this pack (GradientImage V2, Name To Color) have a size_as input that accepts any upstream value and uses it to match dimensions instead of a preset dropdown. Wire original_size into one of those and your gradient or color swatch generates at exactly the reference image's resolution, no manual retyping.

How to install it

Search ComfyUI Layer Style in ComfyUI Manager and install, or do it by hand:

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

Restart ComfyUI. You'll find it under 😺dzNodes → LayerUtility. This particular node needs nothing beyond the base install - no extra models, no heavy dependency to worry about.

Common issues

Honestly, there's not much to trip over - it's a read-only query node. The one thing worth knowing: ComfyUI stores images as a batch, so if you feed it a batch of several images (from a Load Image List or similar), it reports the dimensions of that batch's shape, which only makes sense if every image in the batch is the same size - which, for standard image batches in ComfyUI, they always are. If your numbers look wrong, the usual culprit isn't the node, it's that you connected it upstream or downstream of a resize step you forgot was in the graph - GetImageSize is honest about whatever's actually there, so trace the wire back before assuming it's lying to you.

Category😺dzNodes/LayerUtility

Inputs (1)

NameTypeDefaultDescription
imageIMAGE—

Outputs (3)

NameTypeDescription
widthINT—
heightINT—
original_sizeBOX—