Stride Scale Size
The tiny math node that keeps your resolutions divisible
- scaled_width
- scaled_height
- chosen_side
Some nodes earn their keep by being complicated. Stride Scale Size earns its keep by being a calculator. It takes a width and height, scales them by a factor, snaps the result to a stride, and hands back the numbers - no image tensor in, no image tensor out. It's a utils/math node that does one job and does it without fuss.
Why would you want that? Because ComfyUI quietly cares about divisibility. Latents and VAE decode behave better when your dimensions are multiples of 8 (or 16, or 64, depending on what you're feeding), and any resize or crop can leave you with a 1027×769 that should really be 1024×768. Instead of doing the mental arithmetic or stacking math nodes, you wire this in and the numbers come out already snapped.
How it works
The logic is short enough to read in one sitting. It multiplies image_width and image_height by rescale_by, then snaps each to the nearest multiple of stride using the mode you picked: down floors to the stride (so 1027 → 1024 with stride 8), up ceils (1030 → 1032), nearest rounds. It also computes chosen_side, which is just the shorter or longer of the two scaled dimensions depending on side_selector (shortest/longest).
One subtlety worth knowing: the rescale_by widget has a minimum of 1.0, so the stock widget only scales up. The clamp_rescale_min_1 flag (on by default) enforces that too - it pins any factor below 1.0 up to 1.0. If you ever want sub-1 downscaling through this node, you'd feed a smaller value in from another node and turn that clamp off. In practice, upscaling-then-snapping is what the node is for.
Inputs and outputs
The inputs are all numbers: image_width, image_height, rescale_by, stride (default 8), mode (down/up/nearest), side_selector, and clamp_rescale_min_1.
Outputs:
scaled_width,scaled_height- the snapped dimensions, ready to feed into an Empty Latent Image, a KSampler resolution, or a resize node's width/height.chosen_side- whichever side you asked for. Useful when the workflow cares about "longest side ≈ 2048" rather than exact dimensions, which is how a lot of img2img and upscale setups reason.
Installing it
Stride Scale Size ships in Pepehoschi/ComfyUI-PepeUtils (GPL-3.0). Install via ComfyUI Manager (search "ComfyUI-PepeUtils") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Pepehoschi/ComfyUI-PepeUtils
Restart ComfyUI. No extra dependencies - it's pure Python math on top of the standard ComfyUI stack.
The honest take
There's nothing glamorous here, and that's the point. You'll use it as glue: after a resize node where you want the output locked to 8-aligned dimensions, or before an Empty Latent Image when you want a "scale the source by 1.5, snap it, feed it to the sampler" chain that stays reproducible. It's the kind of node you forget you installed until a workflow needs clean divisible sizes - and then it's exactly the one you reach for instead of doing the math by hand for the hundredth time.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image_width | INT | 1024 | — |
| image_height | INT | 1024 | — |
| rescale_by | FLOAT | 1.00 | — |
| stride | INT | 8 | — |
| mode | COMBO | down | 3 options: down, up, nearest |
| side_selector | COMBO | longest | 2 options: shortest, longest |
| clamp_rescale_min_1 | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| scaled_width | INT | — |
| scaled_height | INT | — |
| chosen_side | INT | — |