Nodes/comfyui-jz/jz Edge Sizes
ComfyUI Node

jz Edge Sizes

The long edge answer in two INTs

By j-zhang19·Created about a month ago·Updated 6 days ago· 2
jz Edge Sizes
  • image
  • long_edge
  • short_edge

If you've ever needed "the larger dimension of this image, regardless of whether it's portrait or landscape," you know the drill: Get Image Size, then a math-expression node to compute max(w, h). It's two or three nodes of ceremony every single time. jz Edge Sizes is the two-node version: one INT in, two INTs out. Feed it any image and it hands you long_edge and short_edge - width and height sorted, so you never care about orientation.

That's the entire job, and for a node that simple the value is entirely about removing graph clutter. It pairs naturally with resize targets: feed long_edge into jz Resize Long Edge or any resize node that takes a dimension, and the orientation-agnostic behavior is built in. The node even documents its own reason for existing in the source - "saves the Get-Image-Size + math-expression dance" - which is exactly the kind of honest small-utility design that makes this pack feel like someone scratched their own itch.

How it works

There's nothing to configure. The image tensor in, and the node reads its height and width, then returns (max(w, h), min(w, h)) as long_edge and short_edge respectively. A 1024×768 landscape gives you 1024 and 768; a 768×1024 portrait gives you the same two numbers in the same order. That consistency is the whole point - downstream logic that keys off the long edge stops caring whether the camera was held sideways.

The one thing worth knowing

Because it returns INTs, you can wire the outputs straight into any node with an INT input - a resize node's width, a VAE encode, an aspect-ratio calculator. The classic composition is jz Edge Sizes → jz Resize Long Edge if you have mixed-size images, or jz Edge Sizes → math node if you need half the long edge for a tile size. It's a plumbing node; it exists to make the graph readable, not to do anything clever itself.

Installing it

It ships in the comfyui-jz pack, one clone away:

cd ComfyUI/custom_nodes
git clone https://github.com/j-zhang19/comfyui-jz

Restart ComfyUI and it shows up under jz/image. Or use ComfyUI Manager and search for "comfyui-jz." No models, no GPU, just the pack's usual minimal deps (requests, pillow, numpy).

Anything that goes wrong?

Honestly, not much - the failure surface is a single integer read. The one thing to keep in mind is that it measures the first frame of a batch: if you feed it a batch of mixed sizes, you get the dimensions of frame 0, not "the batch." For mixed-size batches you want jz Resize Long Edge, which handles each frame individually. That's the only real trap, and it's a design decision rather than a bug.

As with everything in this pack, it's a personal utility from a solo author - small, no community footprint, README-as-documentation. For a node this thin that's fine; it does one job, does it visibly, and gets out of your way.

Categoryjz/image

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (2)

NameTypeDescription
long_edgeINT
short_edgeINT