Nodes/ComfyUI_StarNodes/⭐ Starnodes Aspect Ratio Advanced
ComfyUI Node

⭐ Starnodes Aspect Ratio Advanced

Aspect ratio, megapixels and an empty latent — no calculator, no math errors

By Starnodes2024·Created 2 years ago·Updated 2 days ago· 106
⭐ Starnodes Aspect Ratio Advanced
  • image
  • width
  • height
  • Resolution
  • latent
aspect_ratio
megapixel1.0
latent_channelsSDXL / FLUX (4ch)
use_nearest_from_imagefalse
batch_size1

The standard Empty Latent Image node wants raw width and height, which means every SDXL user has a mental table of "16:9 at 1MP is 1344x768" and every new user has a calculator open. Starnodes Aspect Ratio Advanced replaces all of that: pick a ratio from a dropdown, pick a megapixel target, and it hands you the resolved width, height and a ready-to-use empty latent - dimensions already correct, no math errors, no "but is that divisible by 8?" panic.

The wider workflow context matters here: this is a starter-adjacent helper. It plugs straight into your KSampler or the pack's ⭐ StarSampler, and because it emits the latent itself you can go from "empty canvas" to "denoising" with one less node on the canvas. The KB's ecosystem essay calls this the "efficiency node" pattern - consolidating a common multi-node sequence into one compact node - and that's exactly the niche.

How it works

The aspect ratios come from the pack's json/sdratios.json (15 presets, from 1:1 square up through 21:9 ultra-wide and the matching portraits), and the megapixel list runs 0.1 to 10.0 in 0.5 steps. The node multiplies ratio × target megapixels, rounds to a clean resolution, and builds an empty latent in the requested channel layout. The latent_channels dropdown is where beginners actually need to pay attention:

  • SDXL / FLUX (4ch) - the default, right for SDXL, SD1.5 and Flux.
  • SD3.5 (4ch) - same channel count, different model sampling settings.
  • FLUX 2 (128ch) - Flux 2's much wider latent; pick this or your latent will mismatch the model.

Inputs and outputs

  • aspect_ratio - the 15-preset dropdown.
  • megapixel - target output size; 1.0 gives you the classic 1024-ish square.
  • latent_channels - described above. Get this wrong and sampling breaks in confusing ways.
  • use_nearest_from_image - if enabled and you connect the optional image input, it matches the closest ratio to your image instead of the dropdown.
  • batch_size - latent batch count (up to 4096).

Outputs: width (INT), height (INT), Resolution (STRING, e.g. 1344x768 - handy to display or feed into a text node), and latent (LATENT), which is what actually goes into your sampler.

Install

Part of the Starnodes2024/ComfyUI_StarNodes pack:

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

Restart, double-click the canvas, search star. No extra dependencies.

Where people get burned

Mostly the channel count. People plug an SDXL workflow, see FLUX 2 in the list, think "newer is better," and then wonder why the sampler spits errors. Match latent_channels to your checkpoint family and you're fine. Also note the output resolution may differ slightly from the raw math - the pack rounds to model-friendly numbers - so don't be alarmed that 1344x768 isn't pixel-perfect to your target. And if you enable use_nearest_from_image without connecting an image, it silently falls back to the dropdown, which is easy to misread as a bug.

Category⭐StarNodes/Image And Latent

Inputs (6)

NameTypeDefaultDescription
aspect_ratioCOMBO15 options: 1:1 [1024x1024 square], 8:5 [1216x768 landscape], 4:3 [1152x896 landscape], 3:2 [1216x832 landscape], 7:5 [1176x840 landscape], 16:9 [1344x768 landscape], +9
megapixelCOMBO1.021 options: 0.1, 0.5, 1.0, 1.5, 2.0, 2.5, +15
latent_channelsCOMBOSDXL / FLUX (4ch)3 options: SDXL / FLUX (4ch), SD3.5 (4ch), FLUX 2 (128ch)
use_nearest_from_imageBOOLEANfalse
batch_sizeINT11–4096
imageoptIMAGE

Outputs (4)

NameTypeDescription
widthINT
heightINT
ResolutionSTRING
latentLATENT