Light-Tool: Resize Image By Max Size
A 'fit within this box' resize that never upscales
- image
- image
Light-Tool: ResizeImageByMaxSize is the "shrink this so it fits inside this box" node. Give it an image and a maximum width and height, and it proportionally scales the image down until neither dimension exceeds its cap - without touching the aspect ratio, and - here's the part people miss - without ever upscaling.
That last bit is the whole personality of the node. It only ever makes images smaller. If your image is already under the max, it passes through untouched. There's no "Resize Image By Min Size" behavior hiding in here, no surprise enlargement that smears your pixels.
How it works
The math is straightforward and it's worth understanding because it tells you when to trust the node:
ratio = min(max_width / width, max_height / height)
It computes how much you'd need to scale to hit each limit, takes the smaller of the two (the stricter fit), and scales both dimensions by that factor. A 2048×1024 image with max 1024×1024 gets scaled by min(0.5, 1.0) = 0.5 → 1024×512, fitting inside the box with the height comfortably under the cap. If the computed ratio comes out ≥ 1 - image already fits - it returns the original untouched.
Resizing is done with Pillow, and you get to pick the interpolation via resize_method (default LANCZOS, the sharpest choice for downscaling, with BICUBIC, BILINEAR, and NEAREST as alternatives). The mode input (default RGB) sets the color space before scaling - flip to RGBA if you're resizing transparency-bearing cutouts and want the alpha preserved, or L for plain grayscale.
Inputs and output
- image - the IMAGE tensor.
- max_width / max_height - the box, both defaulting to 512.
- resize_method, mode - as above.
One image out. Wire it into anything that wants a bounded-size image - pre-VAE resizing, tiling, or just throttling a huge reference image before a node that chokes on big tensors.
When it beats a plain resize
If you know your exact target dimensions, ResizeImageV2 in this same pack (or stock ComfyUI's ImageScale) is simpler. Max Size shines when the input dimensions are unknown at design time - a directory of mixed-size images, a Load Image From URL node pulling arbitrary dimensions, or an upscale model whose output size you don't want to reason about. "Just make sure it fits in 1024" is a much more robust instruction than "make it 1024×700."
Gotchas
The two things that trip people up: it never upscales (if you're feeding in a 512px image expecting a 1024px output, this is the wrong node - that's an upscale job), and the output dimensions won't necessarily be a multiple of 8, so don't assume VAE-friendly sizing out of the box. If you need multiples-of-8, pair it with the pack's Safe Image Crop or handle rounding downstream.
Install is the standard pack route - ComfyUI Manager → search ComfyUI-Light-Tool, or clone into custom_nodes, pip install -r requirements.txt, restart. No models to fetch.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| max_width | INT | 5120–8192 | — |
| max_height | INT | 5120–8192 | — |
| resize_method | COMBO | LANCZOS | 4 options: LANCZOS, BICUBIC, NEAREST, BILINEAR |
| mode | COMBO | RGB | 3 options: RGB, RGBA, L |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |