Imgutils Align
Resize to a Max Side, Keep the Ratio, Stop Doing the Math by Hand
- image
- image
Boring, useful, and exactly what you'd want when a tagger or upscaler demands a maximum input size. Imgutils Align takes an image, resizes it so the longest side matches a number you give it, and keeps the aspect ratio - no stretching, no cropping, no mental arithmetic about which dimension is the binding one.
Why you'll reach for it
Plenty of nodes in a real workflow have an input ceiling. WD14 and the other taggers work best under a certain resolution. ControlNet preprocessors want a sane working size. An upscaler gets slower the bigger the source gets. In every one of those cases you want "cap the longest side at X" - and this is the one-node version of that.
ComfyUI's core scale nodes make you pick target width and height yourself, which means either doing ratio math or risking a stretch. This node does the fit for you: feed a portrait, a landscape, or a square and it lands on the same max dimension with the ratio intact.
How it works
It's a wrapper around align_maxsize from imgutils - plain resizing, no model. It makes max(width, height) equal max_size, scaling the short side proportionally. Worth knowing: it normalizes in both directions. A tiny 256px image with max_size at 1024 gets scaled up to fit, just like a huge one gets scaled down. That's usually what you want for feeding a model with a fixed input size; just don't reach for it when you meant "shrink only."
The inputs that matter
Only two, and you'll set one of them:
image- what goes in.max_size(default 1024, 64–8192, step 64) - the target longest side. 1024 is the sweet spot for anime SDXL-era pipelines and most taggers; drop it if a model needs smaller, raise it if you're prepping a big upscale and have the VRAM.
Output is a single image, same aspect ratio, ready to wire anywhere.
Honest take
It's a trivial node and it knows it - that's not a knock. The value is that it's always there in the pack, one drag away, instead of reaching for a scale-by-calculator. The one trap is using it as an upscaler: it's a resize, not a model, so enlarging with it just blurs. If you're in this pack and want to actually upscale anime art with quality, that's what Imgutils Upscale (CDC) is for. A sensible pattern: Align to cap the source, then CDC for the real enlargement.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/xiaden/comfyui-imgutils.git
cd comfyui-imgutils
pip install -r requirements.txt
Or via ComfyUI Manager (search "imgutils"). Requires ComfyUI >= 0.25.0 and Python >= 3.10; the pack's sole dependency is dghs-imgutils[gpu]. No model downloads - this node is pure PIL resizing, so it's instant on CPU and there's no first-run delay.
Troubleshooting
If images come back at a size you didn't expect, check whether you grabbed Align's sibling Squeeze or CDC by mistake - they're in the same dropdown and do different jobs. And remember the two-direction scaling above: set max_size knowing that smaller inputs get stretched up to meet it. If you wanted shrink-only, throw a conditional or a check on the source size in front of it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to resize to max dimension. | |
| max_size | INT | 102464–8192 | Maximum side length. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |