宽高比
Stop doing aspect-ratio math in your head
- width
- height
Every time you set up an Empty Latent Image you do the same arithmetic: "16:9 at what resolution? 1280×720? No wait - is that right?" This node ends that. Pick an aspect ratio from a dropdown and it hands you the width and height as two INT outputs, ready to wire straight into an Empty Latent Image, a latent upscale, or anything that wants dimensions. It's the ComfyUI equivalent of a sticky note with the multiplication table on it.
The presets are pragmatic, not exotic: 16:9 → 1280×720, 9:16 → 720×1280, 4:3 → 1000×750, 3:4 → 750×1000, 2:1 → 1000×500, 1:2 → 500×1000, plus 自定义 (custom). Note the choices aren't multiples of 64 in every case (1000×750 for 4:3, for instance) - fine for SDXL-flavored pipelines, and you can always use the custom field if your model needs cleaner multiples.
The 自定义 mode is where the second input comes in: size is a string in width*height format (the tooltip literally shows the example 800*600). You type 768*512, the node splits on *, and you get width=768, height=512. If you type garbage - wrong separator, negative numbers, letters - the node catches it, prints a warning to the console ("无效尺寸输入"), and falls back to 1024×1024 rather than crashing. That silent fallback is both a kindness and a trap: a mistyped custom size gives you a perfectly square latent and zero fanfare.
Inputs: mode (the preset dropdown, default 自定义) and size (the custom string, default 1024*1024). Outputs: width (INT) and height (INT). The standard wiring is those two INTs into Empty Latent Image → width/height, which keeps all your resolutions in one visible place instead of scattered across workflow widgets.
Install: part of ComfyUI-My-Nodes - ComfyUI Manager → search "ComfyUI-My-Nodes", or git clone https://github.com/Tagbliton/ComfyUI-My-Nodes into custom_nodes and restart. Pure local utility: no API key, no network.
Gotchas. The two worth remembering: (1) the custom parser only accepts * as the separator and rejects anything non-numeric - 800 x 600 or 800×600 (that's a multiplication sign, not an asterisk) silently falls back to 1024×1024; (2) if you pick a preset, the size field is ignored entirely, so don't "helpfully" edit both. There are fancier aspect-ratio nodes out there with model-aware presets and latent outputs, but for "give me two integers," this is the one that ships with the pack you've already installed.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | 自定义 | 8 options: 自定义, 16:9, 9:16, 4:3, 3:4, 2:1, +2 |
| size | STRING | 1024*1024 | 输入格式:宽度*高度(例如:800*600) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |