Nodes/ComfyUI-Light-Tool/Light-Tool: Ratio Padder
ComfyUI Node

Light-Tool: Ratio Padder

Force any image into a target ratio with centered padding

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Ratio Padder
  • image
  • image
target_ratio1:1
custom_ratio
base_size1024
color_hex#FFFFFF
use_hextrue
R255
G255
B255

Light-Tool: AspectRatioPadder (display name "Ratio Padder") solves the "my image is 4:3 but the slot needs 9:16" problem. It resizes your image to fit inside a target aspect ratio, then pads the leftover space with a solid color so the output is exactly that ratio - no cropping, no distortion, no losing part of the subject. It's the letterboxing node.

This is the difference between a quick hack and a reusable pattern. Plain cropping to force a ratio throws away pixels; stretching distorts the subject; this node keeps everything and fills the void. It's what you want for thumbnails, social platforms with fixed slots, video-adjacent workflows, or any downstream node that demands a specific aspect.

How it works

Pick a target_ratio from the presets (1:1, 9:16, 16:9, 4:3, 3:2, 2:3), and the node builds a canvas around base_size - which is the width for landscape ratios and the height for portrait ones, i.e. effectively the long edge. Both canvas dimensions get snapped to a multiple of 8. Your image is then scaled with LANCZOS to fit inside (never overflowing either side), centered, and pasted onto the canvas. Whatever space remains becomes the padding color - white by default, settable via the same color_hex / R / G / B + use_hex machinery the pack's other compositing nodes use.

The relevant inputs: target_ratio, base_size (default 1024), and the color controls. Output is one image.

The trap in custom_ratio

Here's where people get burned. There's a custom_ratio string field that looks like it accepts arbitrary ratios like "16:10" or "21:9". It doesn't. Internally, the node looks up the string in the same preset list - so custom_ratio only works if you type one of the exact preset strings. Anything else (say "16:10") silently falls through and the node returns your image unchanged, no error, no padding, no warning.

If you need a ratio that isn't in the six presets, you're better off handling it with separate resize and pad steps, because this node will quietly no-op on you. That silent fallthrough is the single most reported confusion around this node.

When to reach for it

  • Filling fixed-ratio slots - square feed thumbnails, 16:9 previews, 9:16 stories.
  • Feeding strict-aspect downstream nodes that reject mismatched inputs.
  • Batch consistency - dump mixed-aspect images in, get uniform-ratio images out, every time.

The trade-off is the padding itself: if your subject fills the frame edge-to-edge, padding produces big empty bars, and you might prefer a crop instead (the pack's CropImage or Safe Image Crop). If you'd rather pad, this is the cleanest one-node route in the pack.

Install

Standard: ComfyUI Manager → search ComfyUI-Light-Tool, or clone into custom_nodes, pip install -r requirements.txt, restart. It lives under ComfyUI-Light-Tool → image → Resize. No models or downloads.

CategoryComfyUI-Light-Tool/image/Resize

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
target_ratioCOMBO1:16 options: 1:1, 9:16, 16:9, 4:3, 3:2, 2:3
custom_ratioSTRING
base_sizeINT102464–4096
color_hexSTRING#FFFFFF
use_hexBOOLEANtrue
RINT2550–255
GINT2550–255
BINT2550–255

Outputs (1)

NameTypeDescription
imageIMAGE