Mpi Scaled Dimensions
Scale to a target size without breaking the aspect ratio
- image
- scaled_width
- scaled_height
- is_portrait
- scaled_image
When a workflow needs an image at "about 720p," you can't just type a width and height - the aspect ratio has to survive, or you get squashed faces and stretched buildings. MpiScaledDimensions is the proportional-resize node: feed it an IMAGE, tell it a target size, and it figures out the matching width and height for you, then hands back the actual resized image plus the computed dimensions as integers.
The four outputs are the whole point, and they make it a great upstream for anything resolution-hungry:
- scaled_width / scaled_height - the computed dimensions as
INTs, ready to feed an Empty Latent or a video node. - is_portrait - a
BOOLEANtelling you whether the image is taller than wide. Handy for aspect-aware routing. - scaled_image - the image actually resized to those dimensions, so you never have to re-derive the size separately.
How it works
Simple proportional math: it takes the size you gave it, divides by whichever side you chose as the anchor (the max side or the min side), and scales the other dimension by the same factor. Then it resizes through comfy.utils.common_upscale with your chosen interpolation.
The inputs to care about:
- image - what you're scaling.
- size - the target for the anchor side. 0 means "return the original dimensions" and pass the image through unchanged.
- side - the
use_max/use_mintoggle.use_maxsizes the longer side tosize(the common "fit to 720" case);use_minsizes the shorter side, which gives you a larger result. - upscale_method - interpolation for the
scaled_imageoutput:lanczos,bicubic,bilinear,nearest-exact,area. Defaultlanczosis the right call for upscaling.
Install
Part of the ComfyUi-MpiNodes pack. ComfyUI Manager (search "MpiNodes" / publisher "mad-pony-interactive"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes
Restart. No model downloads, no extra Python deps.
Where people trip
The output is proportional, not a crop - scale 720p to a target of 720 and a portrait image comes back 720 tall and ~405 wide, not 720×720. If you need a fixed square, this isn't the node; if you need a valid model resolution, it is, but chain it into MpiRoundToMultipleRes to snap both sides to the model's stride - a 405-wide dimension will make your video sampler unhappy. And remember size = 0 is "leave it alone," which trips people expecting "size 0 means tiny." Also: it upscales in both directions - downscaling a 4K image to 720 works fine, but lanczos on a downscale is more work than needed, so area or bilinear are cheaper choices when shrinking.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| size | INT | 7200–4096 | If 0, it will output the original dimensions |
| side | BOOLEAN | true | — |
| upscale_method | COMBO | lanczos | Interpolation used to resize the scaled_image output. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| scaled_width | INT | — |
| scaled_height | INT | — |
| is_portrait | BOOLEAN | — |
| scaled_image | IMAGE | — |