PDselector-string
PDselector-string makes canvas math boring
- string
- int
The node is a lookup table pretending to be a switch
PDselector-string (class PDStringSelector) does exactly one boring thing, and it's great at it: you pre-fill three values for the ratios 2:3, 1:1, and 3:2, pick an aspect_ratio, and it hands you back whichever value matches - as both a string and an int. It's from 7BEII's Comfyui_PDuse pack, a grab-bag of image/text utilities, and it lives in the pack's ratio-selector family.
Why would you reach for it? Any workflow that flips between aspect ratios - a batch job iterating 2:3 and 3:2, a "choose your output size" workflow you share around - needs those sizes defined in one place so a sampler, a crop node and a filename all stay in sync. This node is that one place. It's plumbing in the truest sense: no pixels, no magic, just a value you change once instead of hunting through five nodes (see the KB's comfyui-node-plumbing.md for the whole philosophy).
How it works
The source is six lines of logic. The three ratio names aren't a dropdown - they're literally the names of three STRING inputs ("2:3", "1:1", "3:2"), each with a default (768, 680, 1024). When the node runs, it strips whitespace off aspect_ratio, looks it up in that dict, and if the key isn't there it silently falls back to the 2:3 slot. Output is the matched value plus int(float(value)) so you get both a string and a usable integer.
That fallback is the one thing that'll bite you. Type "3 : 2" with spaces and it still works (stripped). Type "16:9" - a perfectly reasonable ratio that this node doesn't have a slot for - and you get the 2:3 value with zero warning. The node has no notion of "invalid", only "not found".
The inputs and outputs that matter
aspect_ratio- the key. Type it or wire it in from upstream."2:3","1:1","3:2"- the three slots. Keep these numeric strings. The node parses the value withfloat(), so a slot containing"auto"will throw and error out the whole run.- Outputs:
stringandint- same value, two types. Wire the int into a resolution or seed; wire the string into a filename.
To drive the slots from another node (say a shared size value), right-click each slot and pick Convert widget to input - that's the standard ComfyUI mechanic, and it's how this stops being three manual boxes and becomes part of a bigger graph.
Installing it
This ships inside Comfyui_PDuse, so you install the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse.git
cd Comfyui_PDuse
pip install -r requirements.txt
Or search "Comfyui_PDuse" in ComfyUI Manager and let it handle the rest. Restart ComfyUI. No model files, no heavy downloads - the requirements are just xlrd, openpyxl, scipy, numpy, Pillow, torchvision and opencv-python, and most of those already ship with ComfyUI.
The honest take
For one ratio it's overkill - just type the number. Where it earns its keep is a multi-ratio workflow you keep reloading, where the three slots act as your config panel. Just remember the silent 2:3 fallback is a trap, and don't put non-numbers in the slots. Small, sharp, no drama.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| aspect_ratio | STRING | 2:3 | — |
| 2:3 | STRING | 768 | — |
| 1:1 | STRING | 680 | — |
| 3:2 | STRING | 1024 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |
| int | INT | — |