Nodes/ComfyUI-Light-Tool/Light-Tool: Scale Image
ComfyUI Node

Light-Tool: Scale Image

Fit any image into any box — stretch, fill, or pad, decided by one dropdown

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Scale Image
  • image
  • image
width1024
height1024
modeAUTO
R255
G255
B255
A255
aligncenter
resampleLANCZOS
aspect_tolerance0.01

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 A to 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.

CategoryComfyUI-Light-Tool/image/transform

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
widthINT1024
heightINT1024
modeCOMBOAUTO4 options: AUTO, STRETCH, FILL, PAD
RINT2550–255
GINT2550–255
BINT2550–255
AINT2550–255
alignCOMBOcenter5 options: center, top-left, top-right, bottom-left, bottom-right
resampleCOMBOLANCZOS6 options: LANCZOS, NEAREST, BILINEAR, BICUBIC, BOX, HAMMING
aspect_toleranceFLOAT0.01

Outputs (1)

NameTypeDescription
imageIMAGE