CompareLengths
The long side and short side of any resolution, without doing the max() yourself
- long
- short
CompareLengths does one tiny thing: feed it a Width and a Height and it hands you back the longer side and the shorter side, no matter which way the image is oriented. Feed it 768x1344 and you get long = 1344, short = 768. Feed it 1344x768 and you get the same two numbers back, just in the same order. That "no matter the orientation" bit is the entire point.
The name is slightly misleading, honestly. It doesn't compare the lengths of lists or strings - it's max and min of two integers, dressed up with a friendlier name.
Why you'd reach for it
Aspect-ratio-aware workflows keep tripping over orientation. Think about "resize by the longest side" or "make sure the long edge is exactly 1024" - you don't want to hardcode which dimension is the long one, because the same workflow has to handle portrait and landscape inputs. Every time you write "if width < height, swap" in your head, this node is the thing that removes the if.
It slots in naturally next to image-size readers and resolution calculators: get the incoming image's dims, feed them in here, and route long into whatever wants the dominant edge (a hires-fix target, an upscale-by-long-side node, a crop box calculator) while short goes wherever you need the minor edge.
How it works
The implementation is about as direct as it gets:
def compareLengthsMittimi(self, Width, Height):
longlength = Width
shortlength = Height
if (Height > Width):
longlength = Height
shortlength = Width
return (longlength, shortlength, )
It's max and min. If they're equal, long and short are just the same value. That's the whole mechanism - there's no list handling and no float support, so don't try to feed it anything fancier than integers.
The inputs that matter
- Width - the first dimension. Default 512, min 1.
- Height - the second dimension. Default 512, min 1.
Both are plain INTs, so you can either type them or wire them straight from a node that reports image/latent dimensions. The two outputs are:
- long - whichever of the two inputs is bigger (Width if there's a tie).
- short - whichever is smaller.
That's the complete inventory. Two in, two out, zero configuration.
Installing it
It's part of mittimi/ComfyUI_mittimiTools, a small personal pack by mittimi whose README says only "some tools." Install it via ComfyUI Manager (search ComfyUI_mittimiTools) or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/mittimi/ComfyUI_mittimiTools
Restart ComfyUI after either method. The only dependency is toml, which ComfyUI already has, so there are no extra installs and no model files to fetch.
Caveats
There's really nothing to troubleshoot on a node this small. A few honest notes: it only takes INTs (min value 1, so you can't represent a zero-length side), it doesn't tell you which side is long - just the values - and this pack is essentially unmaintained, so don't expect the feature set to grow. For a ten-line helper that's a fair trade. You could reproduce it with a math node and a compare, but this keeps the intent visible in the graph, which is worth something when you come back to a workflow six months later.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| Width | INT | 5121–2147483647 | — |
| Height | INT | 5121–2147483647 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| long | INT | — |
| short | INT | — |