Image Resize And Crop Node
Resize-and-crop an image to exact dimensions
- image
- IMAGE
You need every image to come out at an exact size - 512x512, 1024x1024, whatever - and you don't want them squished. This node does the "cover" move: it scales your image up or down until it fills the target box, then crops off whatever spills over. No stretching, no distortion, no letterbox bars. The trade is that you lose the edges that don't fit, and alignment lets you choose which edges get sacrificed.
If you've ever set object-fit: cover in CSS, this is that, as a ComfyUI node. The default is 224x224, which is a dead giveaway the author uses it to prep images for encoders and datasets - but it's just as good for forcing a clean 1024x1024 before a sampler.
How it works
The image is resized so the target rectangle is completely covered - the shorter side matches, the longer side overhangs - and then the overhang is cropped away. alignment decides where the crop is anchored: center keeps the middle (the sane default), left-top keeps the top-left corner, right-bottom keeps the bottom-right, and so on through ten combinations. So if your subject sits in the top of the frame, center-top stops the crop from lopping off their head.
resampling picks the interpolation filter, and lanczos is the right default - it's the sharp, non-generative downscaler the community reaches for when you just need fewer or more pixels without inventing detail.
The inputs and outputs that matter
image- the image in.width/height- the exact output size. This is the point of the node.alignment- which region survives the crop.centerunless your subject is off-center.
Two more you'll rarely change: resampling (lanczos/nearest/bilinear/bicubic - keep lanczos) and supersample (true/false - render larger then downsample for cleaner edges, at some cost).
Output: a single IMAGE at exactly width x height, ready to wire anywhere.
Installing it
ComfyUI Manager: search ComfyUI_Nimbus-Pack, install, restart. If the registry doesn't list this small pack, clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/sergekatzmann/ComfyUI_Nimbus-Pack.git
pip install -r ComfyUI_Nimbus-Pack/requirements.txt
Restart. This node is plain PIL/NumPy - no models, nothing heavy. The requirements.txt is mostly there for the pack's video node.
Common issues & troubleshooting
It crops, it doesn't pad. If you can't afford to lose any of the image, this is the wrong node - you want the pack's Image Square Adapter instead, which pads to a square with a fill color and keeps the whole picture. Resize-and-crop is for when filling the frame matters more than keeping the corners.
Your subject got beheaded. Change alignment. center crops equally from all sides, which is wrong when the important part is at the top or bottom. Pick the anchor that keeps your subject.
Edges look soft or jagged. For heavy downscales, flip supersample to true - it renders at a larger interim size and scales down, which cleans up aliasing on fine lines. It's slower, so only turn it on when you can see the problem.
nearest looks blocky. That's expected - nearest is for pixel-art or mask-like images where you want hard edges. For photos and renders, stay on lanczos.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 2241–10000 | — |
| height | INT | 2241–10000 | — |
| alignment | COMBO | center | 10 options: center, left-top, left-center, left-bottom, center-top, center-center, +4 |
| resampling | COMBO | lanczos | 4 options: lanczos, nearest, bilinear, bicubic |
| supersample | COMBO | false | 2 options: true, false |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |