ComfyUI Node

HT Smart Resize

Resize images and latents to a model-friendly size, minus the guesswork

By ArtHommage·Created 2 years ago·Updated about a year ago· 4
HT Smart Resize
  • image
  • latent
  • resized_image
  • resized_latent
divisible_by8
interpolationbicubic
scaling_modeshort_side
crop_or_pad_modecenter

Every diffusion model cares about resolution, and most care about divisibility. Feed an SD model a width that isn't a multiple of 8 (or worse, of 64) and you get black bars, cropping, or a silent quality drop. HT Smart Resize exists to make that problem disappear: it resizes your image or latent to a size that divides cleanly, preserving aspect ratio, and gives you control over how the leftover space gets handled. It's the "prepare input for the sampler" node you'll reach for constantly once you've been burned once.

How it works

Four settings, and the first two are the ones that matter:

  • divisible_by - 8 or 64. The target dimensions get snapped to the nearest multiple of your choice. 8 is the SD-family baseline; 64 is what FLUX and other DiT models want (they typically require multiples of 64). When in doubt, match it to your model's requirement.
  • scaling_mode - short_side or long_side. Which edge defines the size target. short_side keeps the smallest edge at a sane resolution (good for not blowing up memory), long_side caps the biggest edge (good for model input constraints).
  • interpolation - nearest, linear, bilinear, bicubic, area, lanczos. bicubic is the default and the sane default; lanczos for the sharpest result at a speed cost; nearest only if you're upscaling pixel art.
  • crop_or_pad_mode - center (default), top, bottom, left, right. After scaling, the image may not match the target exactly, and this decides how the difference is handled - crop the overflow or pad the gap, anchored where you choose. Center crop is the "keep the middle of the composition" choice.

The genuinely useful part: it takes both an image (optional) and a latent (optional) and returns both resized_image and resized_latent. So you can keep an image and its latent in lockstep through a resize - which is the classic img2img/hires-fix setup where you want the latent resized without decoding, re-encoding, and drifting.

How it's grounded

The mechanism is straightforward PyTorch: F.interpolate with antialiasing on for the smooth interpolations, then a crop/pad pass to land exactly on the divisible target. The resize-and-crop flow is the same family of ideas the KB's upscaling and inpainting essays describe - prepare a clean, correctly-sized input before the model sees it, rather than letting the model choke on a wrong-sized one.

When you'd reach for it

  • Any time you're about to feed a non-standard-sized image into a sampler or a model with resolution requirements.
  • Latent-space resizing for img2img at higher resolution (image + latent in one node).
  • Standardizing a batch of differently-sized images before a batch pass.

Installing

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/ArtHommage/HommageTools.git
cd HommageTools && pip install -r requirements.txt

restart, or Manager → "HommageTools for ComfyUI". No models, no extra dependencies.

The honest take

This is one of the pack's most quietly valuable nodes - "resize correctly for the model" is a problem everyone hits and a surprising number of stock nodes get wrong. The trap is the crop: a center crop silently deletes the edges of your composition, and if you've prompted something important near a border, it's gone. Set crop_or_pad_mode deliberately, and when the exact target size matters more than your composition, consider padding instead of cropping. Alpha disclaimer applies as always, but the divisibility math is simple enough to survive updates.

CategoryHommageTools

Inputs (6)

NameTypeDefaultDescription
divisible_byCOMBO82 options: 8, 64
interpolationCOMBObicubic6 options: nearest, linear, bilinear, bicubic, area, lanczos
scaling_modeCOMBOshort_side2 options: short_side, long_side
crop_or_pad_modeCOMBOcenter5 options: center, top, bottom, left, right
imageoptIMAGE
latentoptLATENT

Outputs (2)

NameTypeDescription
resized_imageIMAGE
resized_latentLATENT