ImageCropByRatioAndResize
ImageCropByRatioAndResize — crop to the ratio, then resize to the exact pixels
- image
- IMAGE
- width
- height
ImageCropByRatioAndResize is the one-stop version of the pack's crop utility: it crops an image to a target aspect ratio and resizes the result to the exact pixel dimensions you want. Where the plain ImageCropByRatio leaves you at native resolution and only gives you the ratio, this node nails down the whole job - crop to the aspect, then resize to width_ratio_size × height_ratio_size - so what comes out is exactly the size a model or latent expects.
How it works. Two stages in one pass. First it trims the wider axis so the image matches the aspect ratio implied by your two size numbers - same crop math as ImageCropByRatio, same position control for whether you keep the center, top, bottom, left or right. Then it resizes the crop to the exact target pixels using the interpolation you pick:
lanczos- the quality option; slower, but the one you want for anything that's going into a model or up on a wall. Note it uses ComfyUI's own lanczos implementation, not a naive resize.bicubic,bilinear- solid middle ground, usually fine for feeding latents.nearest,nearest-exact- pixel-art / hard edges; fast but aliases badly.area- good for downscaling when you want to avoid aliasing artifacts.
Inputs and outputs. image (IMAGE), width_ratio_size (INT, default 512), height_ratio_size (INT, default 512), position (enum: center/top/right/bottom/left), interpolation (enum: nearest/bilinear/bicubic/area/nearest-exact/lanczos). Outputs: IMAGE plus width and height INTs - which, unlike the ratio-only node, are your exact target pixels.
The trap. The two size numbers do double duty: they define the aspect ratio and the output resolution. Set them to the actual pixels you want out - if you want a 16:9 video frame at 1280 wide, you'd use width_ratio_size=1280, height_ratio_size=720. If you set them to "the ratio as small numbers" like 16 and 9, you get a 16x9 image, which is probably not what you meant. Beginners hit this constantly.
When you'd use it. Prepping images and video frames for latent encoding at a model's native aspect, standardizing a batch of images to one resolution, or cropping-then-resizing reference frames for img2vid. If you don't need the resize step, the plain ImageCropByRatio is lighter; if you're processing a whole batch, the ImagesCropByRatioAndResizeBatch variant does this per-image and concatenates.
Install. One pack:
ComfyUI Manager → search "komojini-comfyui-nodes" → Install → restart
or cd ComfyUI/custom_nodes && git clone https://github.com/komojini/komojini-comfyui-nodes. No models. For a more battle-tested equivalent, the essentials ecosystem has several crop-and-resize nodes - but this one is perfectly fine, and it's the only one that comes bundled with the rest of the komojini video stack.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width_ratio_size | INT | 5121–8192 | — |
| height_ratio_size | INT | 5121–8192 | — |
| position | COMBO | 5 options: center, top, right, bottom, left | |
| interpolation | COMBO | 6 options: nearest, bilinear, bicubic, area, nearest-exact, lanczos |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |