Light-Tool: Scale Image
Fit any image into any box — stretch, fill, or pad, decided by one dropdown
- image
- image
ComfyUI's core resize nodes ask you for a width and a height and then mostly just stretch or thumbnail. This one is the "fit image into a box" node with actual opinions: it can stretch, crop-to-fill, or letterbox with a background color - and its default AUTO mode picks between stretching and padding for you based on how far the aspect ratios actually diverge.
What the modes mean
You give it a target width and height (default 1024×1024) and a mode:
- AUTO - compares your image's aspect ratio to the target's. If they're within
aspect_tolerance(default 0.01), it stretches; otherwise it pads. This is the sensible default: slightly-off images get cleanly fitted, wildly-off ones don't get smeared. - STRETCH - forces the image to exactly width×height, ignoring aspect ratio. Use it when you genuinely don't care about distortion.
- FILL - scales up until the box is covered, then crops the center. The "cover" mode, great for making a wallpaper fit a canvas with no bars.
- PAD - scales down to fit inside the box, then fills the leftover space with your background color. The letterbox mode.
The fiddly bits live in PAD (and AUTO when it picks padding). The align dropdown (center, top-left, top-right, bottom-left, bottom-right) decides where the fitted image sits on the canvas. The background color comes from R, G, B, and A (defaults 255/255/255/255 - white, opaque). resample gives you LANCZOS through HAMMING (LANCZOS default; the KB's upscaling essay is the place to go if you want the argument for why Lanczos is the boring, correct default).
Where it fits
This is a pixel-space utility, not a latent one. Its natural jobs: normalizing a batch of varied images to one canvas size before an img2img or ControlNet pass, prepping a fixed-size input for tiled processing, or letterboxing a portrait into a landscape frame for a model that wants a specific aspect. Because it's one node instead of a resize-plus-composite chain, it cleans up graphs where you were kludging this with core nodes.
Output is a single IMAGE tensor - same type it takes in - so it drops anywhere in the pipeline.
Installing it
Part of ComfyUI-Light-Tool by Hmily. ComfyUI Manager → search "ComfyUI-Light-Tool" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ihmily/ComfyUI-Light-Tool
pip install -r requirements.txt
# restart ComfyUI
Pillow-only under the hood, no models, works offline.
Where people get burned
- AUTO pads when you wanted FILL. If you're making tiles or covers, AUTO's "preserve content" bias will letterbox instead of crop. Pick FILL explicitly.
- PAD + transparent backgrounds. The RGBA background is respected - set
Ato 0 if you want a transparent letterbox bar. - It doesn't guarantee a latent-safe size. 1024×1024 is fine, but if you scale to an arbitrary number that isn't a multiple of 8, you're reintroducing the VAE problem this pack's Safe Image Crop exists to solve. Nudge your targets to multiples of 8 (or 64) and pair with that node.
It's the one I'd reach for when a workflow demands "this image, exactly this canvas" without a whole compositing setup behind it.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 1024 | — |
| height | INT | 1024 | — |
| mode | COMBO | AUTO | 4 options: AUTO, STRETCH, FILL, PAD |
| R | INT | 2550–255 | — |
| G | INT | 2550–255 | — |
| B | INT | 2550–255 | — |
| A | INT | 2550–255 | — |
| align | COMBO | center | 5 options: center, top-left, top-right, bottom-left, bottom-right |
| resample | COMBO | LANCZOS | 6 options: LANCZOS, NEAREST, BILINEAR, BICUBIC, BOX, HAMMING |
| aspect_tolerance | FLOAT | 0.01 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |