Nodes/ComfyUI-EZ-AF-Nodes/EZ Text to Size
ComfyUI Node

EZ Text to Size

Turn '1024x1536, cinematic' into real integers

By ez-af·Created 2 years ago·Updated 3 months ago· 28
EZ Text to Size
    • WIDTH
    • HEIGHT
    text_input1024x1024

    Resolution in ComfyUI is just two integers - width and height - but those integers usually have to come from somewhere. EZ Text to Size is the tiny helper that extracts them from a string, and it's aimed squarely at people who keep resolution in a text file or a loader preset and want it to drive the actual image size. You feed it 1024x1536, cinematic lighting and it hands back 1024 and 1536 as proper INT outputs you can wire into an Empty Latent Image.

    How it works

    The mechanism is one regex: it pulls every number out of the input with re.findall(r'\d+', ...), then returns the last two as width and height. Two implications worth knowing. First, it doesn't care about format at all - 1024x1536, 1024 x 1536, Width: 1024 Height: 1536, they all work, because only the digits matter. Second, "last two" means if your string contains other numbers, they change the answer. 2048, 1024x1536 gives you 1024 × 1536; 1024x1536, 768 gives you 1536 × 768. That's almost certainly a surprise when you hit it, so keep resolution strings clean of stray digits.

    It's also deliberately forgiving: empty input returns None (it logs a friendly message to the console), and anything with fewer than two numbers returns None too, so a bad string fails downstream at the Empty Latent node instead of silently generating at some wrong size. The default input is 1024x1024, which is a nice touch - you can wire nothing and still get a sensible 1:1.

    The one input

    text_input - a STRING. It's not forced-input, so you can just type the size right in the widget, or wire it from a loader output (this is the natural pairing: EZ Prompt Loader / EZ CSV Loader preset contains a size line, this node turns it into numbers). The two outputs, WIDTH and HEIGHT, plug straight into Empty Latent Image or any node that takes INT dimensions.

    Install

    It's part of the EZ-AF Nodes pack - install the pack once, get all the nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ez-af/ComfyUI-EZ-AF-Nodes.git
    

    then restart, or use ComfyUI Manager → search ez-af. No models, no heavy deps.

    Where people get burned

    The "last two numbers" rule is the whole failure mode, and honestly if your presets are well-formed (1024x1536 as a standalone value) you'll never hit it. The other gotcha: numbers are read as plain integers, so a resolution written as 1024.0x1536.0 isn't parsed by the \d+ regex the way you'd hope. If you keep sizes in a CSV column next to a prompt, this node is exactly the bridge you want; just keep the column free of other digits.

    CategoryEZ NODES

    Inputs (1)

    NameTypeDefaultDescription
    text_inputSTRING1024x1024

    Outputs (2)

    NameTypeDescription
    WIDTHINT
    HEIGHTINT