Nodes/ComfyUI_StarNodes/⭐ Star Advanved Ratio/Latent
ComfyUI Node

⭐ Star Advanved Ratio/Latent

Pick a ratio, pick a size, get a perfect latent — no calculator required

By Starnodes2024·Created 2 years ago·Updated 2 days ago· 106
⭐ Star Advanved Ratio/Latent
  • image
  • LATENT
  • WIDTH
  • HEIGHT
ratio16:9
custom_ratio21:9
resolution4 Megapixel (≈ 2000x2000)
custom_width1920
custom_height1080
latent_channels16 (FLUX/QWEN/ZIT)
ratio_from_imagefalse
batch_size1

Every model generation starts with the same little ceremony: "okay, 16:9 at… what resolution was it that Flux likes again?" Star Advanved Ratio/Latent (yes, that's the author's spelling - "Advanved") is the StarNodes answer: pick an aspect ratio and a megapixel target, and it hands you the dimensions rounded to a valid multiple of 16 and a ready-to-use empty latent. No calculator, no double-checking against the model's resolution table.

It lives in ⭐StarNodes/Image And Latent and is one of the pack's most genuinely useful utilities - the kind of node that quietly removes a recurring source of failed generations.

How it works

The node takes a ratio (16 presets from 1:1 through ultrawide, plus custom), a resolution (21 presets from SD through 10+ megapixel, plus custom), and computes the pixel dimensions by fitting that aspect ratio into that pixel budget. Everything gets rounded to a multiple of 16 (the _round_to_multiple logic in the source) - which matters because SD, Flux, Qwen and video models all expect dimensions on an 8/16-pixel lattice, and a 1312×736 that isn't on the lattice is a silent quality killer.

The resolution presets are the star of the show: they're named after real model families - SD, SDXL, Qwen Image (~1328×1328), WAN HD, WAN FullHD - plus plain megapixel targets (2MP through 10MP+). That means you can pick "Qwen Image" and get the exact native-ish size Qwen's ratio table expects, or pick "4 Megapixel" for a big Flux render without doing the math yourself.

Two more inputs do real work:

  • latent_channels - 4 (SD/SDXL), 16 (FLUX/QWEN/ZIT), or 128 (FLUX2). This is the easy-to-miss one. If you generate a Flux latent with 4-channel settings you get garbage; this dropdown builds the empty latent with the right channel count for your model family. New users burn real time on this exact mistake.
  • ratio_from_image - when on, and an image is connected, it picks the closest preset ratio to that image instead of your dropdown choice. Handy for image-to-video setups where the latent must match the source frame's aspect.

Outputs

  • LATENT - the empty latent, sized and channeled correctly, ready for a sampler.
  • WIDTH and HEIGHT - the computed integers, so you can wire the actual numbers downstream (into a conditioning or a text string) instead of guessing.

Installing it

Standard StarNodes install: ComfyUI Manager → search Starnodes → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Starnodes2024/ComfyUI_StarNodes
cd ComfyUI_StarNodes
pip install -r requirements.txt

Double-click the canvas and search star, or browse ⭐StarNodes → Image And Latent.

The trap

latent_channels is the one that bites. The default is 16 (FLUX/QWEN/ZIT), which is right for modern transformer models but wrong for an SDXL workflow - you'll get a latent the SDXL sampler can't consume, and the error message won't tell you why. If you're on SD/SDXL, set it to 4 first thing. Also, the custom_ratio field (default "21:9") is a text string - it's only read when ratio is set to custom, so change the dropdown or your carefully typed ratio is silently ignored.

Category⭐StarNodes/Image And Latent

Inputs (9)

NameTypeDefaultDescription
ratioCOMBO16:916 options: custom, 1:1, 1:2, 3:4, 2:3, 5:7, +10
custom_ratioSTRING21:9
resolutionCOMBO4 Megapixel (≈ 2000x2000)21 options: custom, SD (≈ 512x512), SDXL (≈ 1024x1024), Qwen Image (≈ 1328x1328), WAN HD (≈ 1280x720), 2 Megapixel (≈ 1408x1408), +15
custom_widthINT192016–99968
custom_heightINT108016–99968
latent_channelsCOMBO16 (FLUX/QWEN/ZIT)3 options: 4 (SD/SDXL), 16 (FLUX/QWEN/ZIT), 128 (FLUX2)
ratio_from_imageBOOLEANfalse
batch_sizeINT11–4096
imageoptIMAGE

Outputs (3)

NameTypeDescription
LATENTLATENT
WIDTHINT
HEIGHTINT