Nodes/ComfyUi-MpiNodes/Mpi Scaled Dimensions
ComfyUI Node

Mpi Scaled Dimensions

Scale to a target size without breaking the aspect ratio

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi Scaled Dimensions
  • image
  • scaled_width
  • scaled_height
  • is_portrait
  • scaled_image
size720
sidetrue
upscale_methodlanczos

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 BOOLEAN telling 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_min toggle. use_max sizes the longer side to size (the common "fit to 720" case); use_min sizes the shorter side, which gives you a larger result.
  • upscale_method - interpolation for the scaled_image output: lanczos, bicubic, bilinear, nearest-exact, area. Default lanczos is 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.

CategoryMpiNodes/ImgOps

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
sizeINT7200–4096If 0, it will output the original dimensions
sideBOOLEANtrue
upscale_methodCOMBOlanczosInterpolation used to resize the scaled_image output.

Outputs (4)

NameTypeDescription
scaled_widthINT
scaled_heightINT
is_portraitBOOLEAN
scaled_imageIMAGE