✂️ Smart Align & Crop
Normalize a folder of images to one resolution — reference image or 1080p cap
- images
- reference_image
- images
- out_width
- out_height
Here's a recurring ComfyUI pain: you've got a batch of images - a folder of photos, a stack of renders - and they're all different sizes. Some are 800×1200, some are 2000×900, one is a weird 3456×5184 phone shot. And your next stage (img2img, ControlNet preprocessing, a training-crop, whatever) wants them all at the same resolution. Feed them in mismatched and either everything gets distorted or the graph falls over.
✂️ Smart Align & Crop is the "make them all one size" node, and it solves the problem in the right way: by scaling to cover and center-cropping, so no image gets stretched. It handles a batch, and it has two modes depending on whether you have a reference.
The two modes
With a reference_image connected: every input image is scaled so it fully covers the reference's dimensions, then center-cropped to exactly match. The output width/height are the reference's, every frame lands at that exact size, and - because it's scale-then-crop, not squeeze - the aspect ratios of your source images are preserved inside the frame. This is the "align everything to this one image's canvas" mode, and it's the right tool when you're prepping a set of images for a comparison grid, a dataset, or a consistent batch pipeline.
Without a reference: each image is downscaled proportionally to fit within max_width × max_height (defaults 1920×1080). No crop in this mode - it just scales the long edge down until both dimensions fit, so a 4K photo becomes ≤1920×1080 without losing any content. It's a "cap the resolution" mode, which is what you want before a memory-hungry pass.
resample picks the downscale filter: Lanczos is the default and recommended, with Bicubic, Bilinear, and Nearest for when you specifically want a softer or harder interpolation.
The outputs
images- the processed batch, all at the target size.out_width/out_height- the actual output dimensions as INTs, so downstream nodes can read them rather than assume.
Where it fits
The most useful setup is pairing it with this pack's Folder Image Loader: load a folder of mixed-resolution images → Smart Align & Crop with a reference (or a max cap) → feed the normalized batch into img2img or a ControlNet pass. That's a complete "process this folder at a consistent resolution" chain with no per-image fiddling.
Installing it
Part of the Louis Use pack:
cd ComfyUI/custom_nodes
git clone https://github.com/LouisLU1997/ComfyUI-louis-use Louis_use
Or "Louis Use" in ComfyUI Manager, then restart. No extra dependencies - PIL resampling.
What to watch
- Reference mode crops. If an input image is much wider than the reference's aspect ratio, you'll lose the left/right edges. That's the price of uniform canvas; if you can't afford the crop, you want a pad node instead (this pack's Image Pad Color is the natural swap).
- Capping mode doesn't crop. Without a reference you get proportional fits, so outputs can still differ from each other - it guarantees within bounds, not identical. If you need everything identical, connect a reference.
- 1080p default may downscale. If your inputs are already under 1920×1080, nothing happens - good. If you wanted 4K, raise the caps.
It's a small node with a clear job, and for batch pre-processing it's the difference between a graph that works and a graph that needs babysitting.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| resample | COMBO | Lanczos(推荐) | 4 options: Lanczos(推荐), Bicubic, Bilinear, Nearest |
| reference_imageopt | IMAGE | 连接参考图后,所有输入图等比缩放并居中裁切到与参考图完全相同的尺寸。不连接则每张图自动等比缩小到 max_width×max_height 以内。 | |
| max_widthopt | INT | 192064–8192 | 无参考图时的最大宽度(默认 1920) |
| max_heightopt | INT | 108064–8192 | 无参考图时的最大高度(默认 1080) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| out_width | INT | — |
| out_height | INT | — |