Fit Size From Int (FS)
The bounding-box math node, no image required
- Fit Width
- Fit Height
- Aspect Ratio
This is the plainest node in the whole Fit Size pack, and the author says as much in the README: it's "the basic math of fitting some content within a bounding box." You give it a width, a height, and a max size, and it hands back the scaled-down (or scaled-up) width and height that keep the aspect ratio intact. No image ever touches this node - it's pure arithmetic.
That makes it the odd one out here, and also the most reusable. Every other node in the pack does this same math internally, but bundles it with loading, resizing, or VAE-encoding an actual image. This one is for when you already have numbers - from metadata, a config widget, another node's output, whatever - and just want the fitted result without needing an image anywhere in the graph.
Why you'd reach for it
Say you're building a workflow that needs to size an EmptyLatentImage to match some external dimensions (a canvas size pulled from an API response, a resolution typed into a primitive node, whatever), but you want to cap it at a sane max so you don't accidentally kick off a 4000×3000 render. Wire your width/height ints in, set a max, and the output feeds straight into your latent node. It's also handy for prototyping: you can test the pack's fit logic with two primitive INT nodes before you've got a real image loaded.
How it works
The math is bounding-box fitting: scale the larger dimension down to max_size, then scale the other dimension by the same ratio to preserve aspect ratio. The pack rounds results to multiples of 8, which is the detail that matters if you're feeding this into anything Stable-Diffusion-adjacent - SD's latent space works in 8-pixel blocks, so a raw fit to, say, 761 would just get rejected or mangled downstream. This node does that rounding for you, so don't be surprised when your output isn't exactly max_size.
The inputs and outputs that matter
- original_width / original_height (INT) - the source dimensions you're fitting. Plug in ints from anywhere: a primitive, a metadata reader, a manual value.
- max_size (INT, default 768, step 8) - the ceiling for the longer side. Bump it in steps of 8 to stay grid-aligned.
- upscale - false or true. Off by default, meaning the node only ever shrinks. Flip it on if your input might be smaller than
max_sizeand you want it scaled up to fill that box too.
Outputs: Fit Width, Fit Height (both INT), and Aspect Ratio (FLOAT). Wire Fit Width/Fit Height into an EmptyLatentImage, an upscale node's target size, or anywhere else that wants a resolution. Aspect Ratio is there if some downstream node wants the ratio directly rather than recomputing it from width and height.
Installing it
Through ComfyUI Manager: search "Comfy Fit Size" or "fitsize" and install. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/bronkula/comfyui-fitsize.git
Restart ComfyUI. No models to download and nothing heavy in the dependency chain - this is a small, self-contained math/image-ops pack, so install is genuinely just clone-and-restart. After restart you'll find this node under Fitsize → Numbers in the node browser (that's the pack's own category grouping, separate from the image-handling nodes).
Common issues
Because there's no image and no VAE involved, there's not much to go wrong here beyond the usual "forgot to restart ComfyUI after cloning" and missing-node errors if you load a shared workflow before the pack is installed. The one thing worth internalizing up front: the 8-pixel rounding means your fitted output is very rarely exactly max_size - that's by design, not a bug, and it's the same behavior every node in this pack shares.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| original_width | INT | — | |
| original_height | INT | — | |
| max_size | INT | 768 | — |
| upscale | COMBO | 2 options: false, true |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| Fit Width | INT | — |
| Fit Height | INT | — |
| Aspect Ratio | FLOAT | — |