Nodes/ComfyUI-Magic-Assistant/📏 多功能图像缩放 Magic Multi-Function Image Resize
ComfyUI Node

📏 多功能图像缩放 Magic Multi-Function Image Resize

Smart resize that keeps your aspect ratio instead of squashing the image

By shigjfg·Created 8 months ago·Updated 11 days ago· 37
📏 多功能图像缩放 Magic Multi-Function Image Resize
  • image
  • latent
  • IMAGE
  • LATENT
mode
resolution1024
scale_ratio1.00
dim_preset
width_px512
height_px512
methodbicubic

Set a plain "resize to 1024×1024" node loose on a 832×1216 image and you get a squashed result - technically resized, useless in practice. Magic Resolution Resize is built around the mode that fixes that: long edge. Tell it "long edge 1024" and it scales the image so the longer side hits 1024 and the other side follows proportionally. Aspect ratio preserved, no distortion, one field instead of four.

It handles both images and latents, which matters more than it sounds. Feed it an IMAGE and you get a resized IMAGE back; feed it a LATENT and it works in latent space (scaled by 8, so the latent math lines up with the VAE). Feed both and it resizes both. That makes it a natural gatekeeper for img2img - prep your source image to the exact resolution your checkpoint likes before it ever touches the encoder.

The three modes

  • ✨ 长边预设 (Long Edge) - the flagship: resolution sets the target long edge from a preset list (512, 768, 832, 960, 1024, 1152, 1280, 1536, with defaults you can extend). Perfect for "I want SDXL-native output."
  • 🔢 按比例 (Ratio) - scale_ratio multiplies both dimensions (0.1–8.0). A straight scale-up or -down.
  • 📐 指定尺寸 (Dimensions) - explicit width_px/height_px when you actually do want a specific size. The dim_preset dropdown is a convenience that fills those fields from the shared resolution-preset list (same one the pack's Magic Resolution node uses).

The method dropdown is the full interpolation set: nearest-exact, bilinear, area, bicubic, lanczos, bislerp. The default is bicubic, which is the right general-purpose choice. A quick orienting note from the upscaling playbook: interpolation like this only adds pixels, it can't invent detail - so for upscaling work it's the "keep it clean" option, and for downscaling (img2img prep) it's exactly what you want. lanczos is the sharper favorite if you're downscaling and want to keep the edges crisp.

Outputs

IMAGE and LATENT, in that order - both are returned, and whichever input you left unconnected comes back as None. There's a small nicety in the code: output image dimensions get rounded to even numbers so downstream VAE math doesn't choke on odd sizes.

What to know

  • ComfyUI 0.29.0+ required. The V1.4.0 update moved this node onto ComfyUI's official comfy.utils.common_upscale (replacing a raw torch.nn.functional.interpolate call). On an older ComfyUI it won't load; upgrade first, then install.
  • Pass the same image it expects. If you connect only a latent, the IMAGE output is None - don't wire that into an image consumer without checking.
  • Odd-size rounding is intentional. Don't be surprised that a 1001px request comes back even.

Installing

It's part of the Magic-Assistant pack:

cd ComfyUI/custom_nodes/
git clone https://github.com/shigjfg/ComfyUI-Magic-Assistant.git
cd ComfyUI-Magic-Assistant && pip install -r requirements.txt

Restart, find it under "✨ Magic Assistant". No models to download; the only real requirement is a recent ComfyUI.

Category✨ Magic Assistant

Inputs (9)

NameTypeDefaultDescription
modeCOMBO3 options: ✨ 长边预设 (Long Edge), 🔢 按比例 (Ratio), 📐 指定尺寸 (Dimensions)
resolutionCOMBO10248 options: 512, 768, 832, 960, 1024, 1152, +2
scale_ratioFLOAT1.000.1–8
dim_presetCOMBO18 options: SDXL_1024x1024, SDXL_1152x896, SDXL_896x1152, SDXL_1216x832, SDXL_832x1216, SDXL_1344x768, +12
width_pxINT51264–8192
height_pxINT51264–8192
methodCOMBObicubic6 options: nearest-exact, bilinear, area, bicubic, lanczos, bislerp
imageoptIMAGE
latentoptLATENT

Outputs (2)

NameTypeDescription
IMAGEIMAGE
LATENTLATENT