📏 多功能图像缩放 Magic Multi-Function Image Resize
Smart resize that keeps your aspect ratio instead of squashing the image
- image
- latent
- IMAGE
- LATENT
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:
resolutionsets 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_ratiomultiplies both dimensions (0.1–8.0). A straight scale-up or -down. - 📐 指定尺寸 (Dimensions) - explicit
width_px/height_pxwhen you actually do want a specific size. Thedim_presetdropdown 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 rawtorch.nn.functional.interpolatecall). 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.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | 3 options: ✨ 长边预设 (Long Edge), 🔢 按比例 (Ratio), 📐 指定尺寸 (Dimensions) | |
| resolution | COMBO | 1024 | 8 options: 512, 768, 832, 960, 1024, 1152, +2 |
| scale_ratio | FLOAT | 1.000.1–8 | — |
| dim_preset | COMBO | 18 options: SDXL_1024x1024, SDXL_1152x896, SDXL_896x1152, SDXL_1216x832, SDXL_832x1216, SDXL_1344x768, +12 | |
| width_px | INT | 51264–8192 | — |
| height_px | INT | 51264–8192 | — |
| method | COMBO | bicubic | 6 options: nearest-exact, bilinear, area, bicubic, lanczos, bislerp |
| imageopt | IMAGE | — | |
| latentopt | LATENT | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| LATENT | LATENT | — |