Nodes/ZF-ComfyUI-Helper/ZF Resolution Selector
ComfyUI Node

ZF Resolution Selector

Turn a ratio, a target, and a rounding rule into exact dimensions

By Z-yaofang·Created 2 months ago·Updated 19 days ago· 1
ZF Resolution Selector
  • image
  • width
  • height
  • megapixels
  • summary
  • source_width
  • source_height
aspect_ratiooriginal
custom_width1024
custom_height1024
scale_modenone
target_length1024
target_megapixels1.00
round_to_multiple8
round_modenearest

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 to custom_width/custom_height if 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 to target_length), width / height (set just that side), or megapixels (solve width and height from target_megapixels while 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) and round_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.

CategoryZF Helper/Settings

Inputs (9)

NameTypeDefaultDescription
aspect_ratioCOMBOoriginal17 options: original, custom, 1:1, 3:2, 2:3, 4:3, +11
custom_widthINT10241–32768Used by custom ratio, and as fallback when original has no image input.
custom_heightINT10241–32768Used by custom ratio, and as fallback when original has no image input.
scale_modeCOMBOnone6 options: none, longest, shortest, width, height, megapixels
target_lengthINT10241–32768Target side length for longest, shortest, width, or height modes.
target_megapixelsFLOAT1.000.01–256Target total megapixels when scale_mode is megapixels.
round_to_multipleCOMBO86 options: 1, 8, 16, 32, 64, 128
round_modeCOMBOnearest3 options: nearest, down, up
imageoptIMAGE

Outputs (6)

NameTypeDescription
widthINT
heightINT
megapixelsFLOAT
summarySTRING
source_widthINT
source_heightINT