NH Ratio Preset Image Resize
When you want to say 'make it 2:3' and mean it
- image
- image
- width
- height
- info
- source_aspect_ratio
- target_aspect_ratio
- selected_preset
- resize_data
Sometimes "closest ratio the model likes" is exactly what you don't want. You want this ratio - a 2:3 output, a 16:9 banner, a 1:1 square - and you want it now, snapped to a resolution your model handles. NH Ratio Preset Image Resize is the manual-control sibling of NH's Smart Ratio Image Resize: you name the ratio, it finds the matching preset and resizes.
Same inputs as the smart version for the most part - image, model_family (the FLUX.2 Klein 4B/9B, FLUX.2 Dev, Qwen-Image, Z-Image dropdown), resolution_level (1–12 MP), resize_method, and pad_color_hex. The difference is you also pick target_ratio from an explicit list - 1:1, 3:4, 2:3, 7:9, 9:16, 9:21, 4:3, 9:7, 3:2, 16:9, 21:9 - and resize_mode takes the slightly different trio of crop, pad, and fill (crop cuts to fit, pad letterboxes, fill stretches).
What happens when your ratio isn't in the table
Here's the honest catch, and it's worth knowing before you hit run: not every model × resolution-level combo carries every ratio. The node looks up your requested ratio in the preset table; if that exact ratio isn't available at the level you chose, it picks the closest one and - this is the good part - tells you. The info output notes the requested ratio, the selected ratio, and the distance between them, and selected_preset names exactly what it used. So you'll never get a 2:3 request silently fulfilled with a 1:1 crop; the node flags the substitution.
Like the smart version, this node emits the full output bundle: image, width, height, info, source_aspect_ratio, target_aspect_ratio, selected_preset, and resize_data. The resize_data hooks into NH Remove Resize Padding downstream, which is how you erase the pad bars added in pad mode once the rest of your pipeline is done with the image.
Smart vs preset: which to reach for
They're the same engine, different dials. Smart Ratio Image Resize reads your source image's aspect and picks the closest preset - you're saying "fit this image to the model." This node ignores the source's aspect and does exactly what you ask - you're saying "make it this shape." Use the preset version when the target shape is the creative decision (a fixed output format for a client, a consistent grid, a specific orientation for a feed) and the source image is just material. Use the smart version when you're feeding a batch of varied images into a pipeline and want each one sized sensibly without hand-tuning.
Install
Part of NH-Nodes:
- ComfyUI Manager → search NH-Nodes → install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI.
No model downloads, no special deps.
Common issues
If your output "doesn't match" the ratio you picked, read info - the node may have substituted a close ratio because the exact one isn't in the model's table at that level; switching model_family or resolution_level usually finds it. And the pad-bars surprise from pad mode is solved by threading resize_data into Remove Resize Padding. One tip: when a target ratio matters for a deliverable, wire target_aspect_ratio or selected_preset into a text node so the decision is documented in the run rather than assumed.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model_family | COMBO | FLUX.2 Klein 9B | 5 options: FLUX.2 Klein 4B, FLUX.2 Klein 9B, FLUX.2 Dev, Qwen-Image, Z-Image |
| resolution_level | COMBO | 1 MP | 12 options: 1 MP, 2 MP, 3 MP, 4 MP, 5 MP, 6 MP, +6 |
| target_ratio | COMBO | 1:1 | 11 options: 1:1, 3:4, 2:3, 7:9, 9:16, 9:21, +5 |
| resize_mode | COMBO | crop | 3 options: crop, pad, fill |
| resize_method | COMBO | lanczos | 8 options: lanczos, bicubic, bilinear, nearest, nearest-exact, area, +2 |
| pad_color_hex | STRING | #FFFFFF | — |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| info | STRING | — |
| source_aspect_ratio | FLOAT | — |
| target_aspect_ratio | FLOAT | — |
| selected_preset | STRING | — |
| resize_data | NH_RESIZE_DATA | — |