ZF Resolution Selector
Turn a ratio, a target, and a rounding rule into exact dimensions
- image
- width
- height
- megapixels
- summary
- source_width
- source_height
There's a class of workflow question that comes up constantly: "I want 16:9, and I want the long side to be 1280, rounded to a multiple of 8." You can do that math in your head, or you can do it wrong in your head, or you can let ZFResolutionSelector do it - which is what this node is for. It takes an aspect ratio, an optional reference image, a target size, and a rounding rule, and outputs exact width and height integers. Nothing else.
That "nothing else" is deliberate. Unlike the pack's EasySize image node, this one doesn't resize images and doesn't create latents. It's a pure calculator - it emits numbers you wire into EmptyLatentImage, sampler helpers, resize nodes, or workflow-setting nodes. If that sounds like the same job as ZFEasySizeSettings, it mostly is, but this one has far more knobs: megapixel targets, reference-image ratios, and six different scale modes.
The modes that cover 90% of use
Three groups of settings do the work:
aspect_ratio-original(use the optional image's own ratio, falling back tocustom_width/custom_heightif no image is connected),custom(use your width/height as both ratio and base size), or one of the fixed ratios: 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, 21:9, 9:21, 2:1, 1:2, 5:4, 4:5, 3:1, 1:3.scale_mode-none(keep the base size),longest/shortest(set that side totarget_length),width/height(set just that side), ormegapixels(solve width and height fromtarget_megapixelswhile keeping the ratio - great when a model cares about total pixels more than any single side).round_to_multiple(1, 8, 16, 32, 64, 128) andround_mode(nearest,down,up) - this is where the node earns its keep, because "round to multiple of 8" with a sensible direction is exactly what latent models want and exactly what people forget to do by hand.
There's also an optional image input, used only when aspect_ratio is original - the node reads its dimensions for the ratio and reports them back on the output.
Outputs
Six of them: width, height, megapixels (the actual MP your final dimensions work out to - useful for sanity checks), summary (a formatted string you can display), and source_width / source_height (the reference image's original dimensions, so downstream nodes can see where the size came from).
Installing it
The pack is dependency-free, so the usual quick install applies:
cd ComfyUI/custom_nodes
git clone https://github.com/Z-yaofang/ZF-ComfyUI-Helper
Restart ComfyUI, or search ZF-ComfyUI-Helper in ComfyUI Manager. No models, no requirements.txt. It's under ZF Helper/Settings.
Where it fits and where it doesn't
This is the node to reach for when you want one resolution setting that drives several downstream nodes consistently - connect width and height to an empty latent and a resize node and they can't drift apart. Where it doesn't fit: anything that actually needs image pixels resized. And there's one subtle behavior worth remembering: in none mode with a fixed ratio, the node uses the larger of your custom sides as the longest side, so none + 16:9 won't silently hand you a 1024x1024. If you want an exact resolution regardless of ratio, set the ratio to custom. Small detail, saves a confusing generation later.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| aspect_ratio | COMBO | original | 17 options: original, custom, 1:1, 3:2, 2:3, 4:3, +11 |
| custom_width | INT | 10241–32768 | Used by custom ratio, and as fallback when original has no image input. |
| custom_height | INT | 10241–32768 | Used by custom ratio, and as fallback when original has no image input. |
| scale_mode | COMBO | none | 6 options: none, longest, shortest, width, height, megapixels |
| target_length | INT | 10241–32768 | Target side length for longest, shortest, width, or height modes. |
| target_megapixels | FLOAT | 1.000.01–256 | Target total megapixels when scale_mode is megapixels. |
| round_to_multiple | COMBO | 8 | 6 options: 1, 8, 16, 32, 64, 128 |
| round_mode | COMBO | nearest | 3 options: nearest, down, up |
| imageopt | IMAGE | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| megapixels | FLOAT | — |
| summary | STRING | — |
| source_width | INT | — |
| source_height | INT | — |