Nodes/ComfyUI 1hewNodes/Int Image Side Length
ComfyUI Node

Int Image Side Length

Grab one number out of an image's dimensions — longest, shortest, width, or height

By 1hew·Created about a year ago·Updated 7 days ago· 33
Int Image Side Length
  • image
  • int
modeshortest

This is the kind of node that looks pointless until the day your workflow needs "the short side of this image as an integer" and you realize nothing in stock ComfyUI hands you that without math nodes stacked three deep. It reads an image's dimensions and outputs a single INT: the longest side, the shortest side, the width, or the height, depending on a dropdown.

If that sounds narrow, it is - and that's the point. ComfyUI workflows are constantly deciding things like "resize so the shortest side is 1024" or "is this image taller than it is wide?", and both of those need an actual dimension as a number you can feed into a conditional or a resize math chain. This node is the missing measurement step.

How it works

Simple and honest: it looks at the image tensor's H×W, then mode decides which one comes out:

  • shortest (default) - min(width, height). The classic "resize by short side" input.
  • longest - max(width, height). For "fit a 4K canvas" logic.
  • width and height - the raw dimensions if you want exactly one of them.

It returns one INT. If the input is malformed it returns 0 rather than crashing, and it shows the value as a text readout on the node - so you can verify what it's seeing at a glance. Batch-wise, it operates on the first frame of the batch; every frame in a normal batch shares dimensions, so that's rarely a problem in practice.

Where it shines is feeding resize logic: pipe this into a math node or a resize node's size input and you've got dynamic sizing that follows whatever the upstream image actually is, instead of hardcoding "1024" and hoping. The pack's sibling Int Image Size gives you width and height as separate outputs; this one is for when you only need one number and want a single clean wire.

Installing it

It ships in 1hewNodes. Install via ComfyUI Manager (search "ComfyUI 1hewNodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart ComfyUI. No dependencies beyond torch, no model downloads.

Common issues

The main thing to remember is that it reports the first frame's dimensions. If you feed it a batch of mixed-size images (possible if you built the batch manually), you're measuring only the head of the batch. And 0 for malformed input is silent - it won't warn you, so if your downstream suddenly gets zeros, check the image actually made it into the node. Otherwise, honestly, there's not much to trip on here. It's a measurement node; the risk is the person reading it wrong, not the node misbehaving.

Category1hewNodes/int

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
modeCOMBOshortest4 options: longest, shortest, width, height

Outputs (1)

NameTypeDescription
intINT