Nodes/ComfyUI 1hewNodes/String Ratio Doubao Seedream 5.0 Pro
ComfyUI Node

String Ratio Doubao Seedream 5.0 Pro

1 Crop — Snap It to One of 8 Shapes Instead

By 1hew·Created about a year ago·Updated a day ago· 35
String Ratio Doubao Seedream 5.0 Pro
  • image
  • string
◄selection1:1►

Doubao Seedream doesn't take a width and a height. You hand it a shape, it hands you pixels. Which means the ratio string feeding that node is a real input with a real wrong answer - and this is the little node that picks the least-wrong one for you.

What it is, and when you'd want it

String Ratio Doubao Seedream 5.0 Pro reads an image, works out its aspect ratio, and outputs the nearest label from the eight ratios Seedream 5.0 Pro actually accepts: 21:9, 16:9, 3:2, 4:3, 1:1, 3:4, 2:3, 9:16. That's the whole node. One string out.

It does not resize anything, generate anything, or talk to a server. No key, no network, no credits.

You'd reach for it because Seedream lives behind ByteDance's API - the Seedream line has never shipped weights, it's a product, not a download - and that API's aspect_ratio field is a fixed menu, not a number pair. The 1hewOffice pack's Doubao Seedream 5.0 Pro node exposes that menu; this node's string output plugs into it. Same author, different pack, so expect to install two things. If you were hoping to run Seedream locally, this isn't the node that changes your mind - but if you're already paying per call, this is the step that stops you wasting calls on shapes the model quietly rounds.

How the matching works

For each image in the batch it computes width / height, then compares it to every preset in log space: |log(image_ratio) - log(preset_ratio)|, lowest difference wins. That matters more than it sounds. Log-space comparison measures relative error, so a ratio halfway off in multiplication terms loses, not one halfway off in subtraction terms. It's the geometrically sane way to snap ratios together, and it's why the results sometimes surprise you:

  • A tidy 2:1 image (say 2048x1024) comes back 16:9. Doubao's menu has no 2:1, and 16:9 is closer by relative error than 21:9.
  • 1280x1024, which is 5:4, comes back 4:3 - there's no 5:4 in the eight.
  • A 3:1 panorama lands on 21:9, the widest thing on the menu.

Batch input is per-frame: each image is matched on its own, and the results are joined with newlines. Two images in, two lines out.

Inputs and output

Two inputs, one output, and you only really set one of them.

selection is the COMBO, default 1:1, and it is the manual answer: leave image unconnected and the node just emits whatever you picked. Useful as a plain string constant you can point at, or when you want the ratio pinned across a whole run.

image is optional and is what makes the node interesting. Connect your reference image and the node infers the ratio from it. For image-to-image work, the docs suggest wiring the same reference into the API node's image_1 as well, so reference and ratio agree.

The output is string - a STRING, ready for the API node's aspect_ratio, or a text node, or a filename pattern if you want the shape visible in your output names.

Installing it

ComfyUI Manager, search 1hewNodes, install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Then restart ComfyUI and let it install the pack's requirements. The requirements.txt is honest about the pack's real identity: opencv-python, scikit-image, scikit-learn, psd-tools, color-matcher, ultralytics, rembg, transparent-background, onnxruntime, av, torchaudio. You are installing a whole image-processing toolkit to get a dropdown that does arithmetic. That's the deal with single-pack installs.

The pack registers nodes through the newer comfy_api.latest V3 schema API, so it wants a reasonably current ComfyUI. On a very old build the pack won't load at all.

Where people get burned

It doesn't resize. "String Ratio" sounds like it outputs pixels. It outputs a word. If you need the pixels, you want Image Resize Doubao Seedream 5.0 Pro from the same pack, and the API node combines that label with the resolution tier to pick the final size.

Batches make multi-line strings. Feed four images and you get four lines. Most downstream inputs want one value. One image per call is the sane habit.

auto isn't here on purpose. The upstream API node has an auto mode that infers the ratio from a reference image, and the author deliberately left it out - this node's job is to emit a concrete ratio you can feed in directly, log, or branch on.

Text-to-image doesn't need it. The Doubao API node has no get_image_size input, so with no reference image you just set aspect_ratio by hand. This node earns its place when you do have an image and want it snapped to one of the eight.

And a pack-level trap worth knowing: v3.28.0 removed the old generic String Resolution node and replaced the generic resolution selector with per-model versions. If you load a workflow from before that and a node is missing, that's why - you swap in the model-specific node, not a reinstall.

Category1hewNodes/text

Inputs (2)

NameTypeDefaultDescription
selectionCOMBO1:18 options: 21:9, 16:9, 3:2, 4:3, 1:1, 3:4, +2
imageoptIMAGE—

Outputs (1)

NameTypeDescription
stringSTRING—