HT Smart Resize
Resize images and latents to a model-friendly size, minus the guesswork
- image
- latent
- resized_image
- resized_latent
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-8or64. 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_sideorlong_side. Which edge defines the size target.short_sidekeeps the smallest edge at a sane resolution (good for not blowing up memory),long_sidecaps the biggest edge (good for model input constraints).interpolation-nearest,linear,bilinear,bicubic,area,lanczos.bicubicis the default and the sane default;lanczosfor the sharpest result at a speed cost;nearestonly 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| divisible_by | COMBO | 8 | 2 options: 8, 64 |
| interpolation | COMBO | bicubic | 6 options: nearest, linear, bilinear, bicubic, area, lanczos |
| scaling_mode | COMBO | short_side | 2 options: short_side, long_side |
| crop_or_pad_mode | COMBO | center | 5 options: center, top, bottom, left, right |
| imageopt | IMAGE | — | |
| latentopt | LATENT | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| resized_image | IMAGE | — |
| resized_latent | LATENT | — |