Ino Image Resize By Longer Side And Crop V2
Fit any image into a fixed canvas — resize to the longer side, then crop or pad
- image
- image
Fixed-size canvases are everywhere in ComfyUI - a ControlNet wants a 512×512 condition, a video model wants 512×768, a batch needs every input at the same resolution. Real images aren't that polite. Ino Image Resize By Longer Side And Crop V2 is the node that forces them into shape: it scales the image so the longer side fits your target, then either crops the excess to hit the exact dimensions or pads the gap, depending on the toggle. One image in, a clean target-sized image out.
This is the "V2" of the pack's resize node, and the upgrade is the crop-position control. V1 just resizes the longer side to a target and leaves you with whatever aspect ratio that produces. V2 gives you a real canvas: explicit target_width/target_height, plus where to crop (or how to pad). If you've ever fought an off-aspect image into a fixed box and lost the composition center in the process, this is the knob you were missing.
How it works
Under the hood it's two stock ComfyUI operations in sequence. First it computes a scale so the longer side matches the target (a wide image targets target_width; a tall image targets target_height) and resizes with ResizeAndPadImage using your chosen interpolation and padding_color. Then, if crop is on, it crops the result down to exactly target_width × target_height at the selected position. If crop is off, you keep the padded (letterboxed) canvas instead.
The resize uses lanczos-class interpolation if you pick it - from the KB, that's the plain "more pixels, no hallucination" path, the right call for preprocessing where you don't want the model inventing detail.
Inputs and outputs that matter
- target_width / target_height - the canvas you're fitting to, both default 512.
- crop - on: crop to exact size; off: pad (letterbox) to exact size.
- position - where to crop:
top-left,top-center,center,bottom-center,bottom-right. Center is the safe default for portraits; top-left suits text/UI-heavy images. - padding_color -
whiteorblack(only matters whencropis off). - interpolation -
area,bicubic,nearest-exact,bilinear,lanczos.
Output: a single image at exactly the target dimensions.
Installing it
Part of ComfyUI-InoNodes (Inoland). ComfyUI Manager → search "ComfyUI Ino Nodes" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/nobandegani/comfyui_ino_nodes
cd comfyui_ino_nodes
pip install -r requirements.txt
Restart after. Requires inopyutils (auto-installed) and a current ComfyUI; no keys or models.
Common issues
One quirk in the source is worth knowing: the x/y offset inputs exist, but the position presets override them - every position option (top-left through bottom-right) sets its own crop origin and ignores what you put in x/y. So in practice you set position, not x/y; the manual offsets only become relevant if the option list grows a "custom" entry. And watch the math on extreme aspect ratios: fitting a 9:16 image into a 1:1 target crops away nearly half the frame, so if you're losing content you care about, choose crop: off and pad instead - or fix the target aspect.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| target_width | INT | 5121–16384 | — |
| target_height | INT | 5121–16384 | — |
| padding_color | COMBO | 2 options: white, black | |
| interpolation | COMBO | 5 options: area, bicubic, nearest-exact, bilinear, lanczos | |
| crop | BOOLEAN | true | — |
| position | COMBO | 5 options: top-left, top-center, center, bottom-center, bottom-right | |
| x | INT | 00–16384 | — |
| y | INT | 00–16384 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |