ZML_双整数V2
Random or indexed resolution from a preset list — for batch variety
- 预设宽
- 预设高
- help
Type in a few resolutions, and this node hands you one of them - by index when you pick a valid one, or at random when you don't. It's the natural next step up from the plain ZML_双整数: instead of two fixed numbers you get a comma-separated preset list for width and a matching list for height, with the choice driven by an index or by randomness. Its natural home is batch generation where you want each render to roll a different aspect ratio without hand-editing the latent size every run.
How it works
Two text fields, 预设宽 and 预设高, each holding comma-separated integers - defaults 832,1024,1216 and 1216,1024,832, which are the standard portrait/square/landscape triple. The node parses both lists, then decides:
- 索引值 > 0 and within range of both lists → pick that position (1-based) from each list.
- 索引值 = 0 or out of range → random choice.
- 随机宽高对应 on → the same index is used for both lists, so you get matched pairs (832×1216, 1024×1024, 1216×832). Off → width and height are chosen independently, so you can roll 832×832 or 1216×1216.
The key engine detail: the node overrides IS_CHANGED to return float("nan"), which tells ComfyUI the result always changes - so random mode genuinely re-rolls on every execution instead of getting cached. That's the mechanism behind "different resolution each run."
The inputs
- 预设宽 / 预设高 - comma-separated integer lists.
- 索引值 - 0–114514. Zero (or out of range) means random.
- 随机宽高对应 - matched pairs vs. independent rolls.
Outputs: 预设宽 (INT), 预设高 (INT), and help (STRING) - the help output is the author's friendly usage essay, worth reading once because it explains the exact index-vs-random behavior.
Installing
Pack standard:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
restart or ComfyUI Manager. Translation patch at https://github.com/zml-w/ZZZ_ZML_English_Patch for English labels.
Common issues
The off-by-one index semantics surprise people: 索引值 1 is the first preset (it does 索引值 - 1 internally), and 0 means random - so you can't "pick the first item" with the default 0. If you want fixed first-item behavior, type 1. Second, list length mismatches: if 预设宽 has 3 items and 预设高 has 4, matched mode truncates to the shorter list and independent mode samples each separately - harmless, but confusing if you didn't mean it. And remember the IS_CHANGED override means every execution re-rolls in random mode, including the first, so a "fixed" workflow with 索引值 0 gives you a different resolution on every run - which is exactly the point for batch variety and exactly the trap if you forgot random mode was on.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 预设宽 | STRING | 832,1024,1216 | — |
| 预设高 | STRING | 1216,1024,832 | — |
| 索引值 | INT | 00–114514 | — |
| 随机宽高对应 | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 预设宽 | INT | — |
| 预设高 | INT | — |
| help | STRING | — |