Budi HartonoandClaude Sonnet 5 17f6fba87b Fix Flux.2 latent shape bug, rebuild node internals, add fast-test presets
Root-cause fix for the reported slowdown/wrong-resolution issue: Flux.2 uses
128 channels at 16x spatial downsample (comfy_extras/nodes_flux.py's
EmptyFlux2LatentImage), not 16ch/8x like Flux.1/Krea/Qwen-Image. We hardcoded
//8 for every model, so Flux.2 latents came out 2x too large per axis (4x the
pixels) — explains both the wrong output resolution and the multi-x s/it gap
versus the native node. Replaced the flat channel map with a per-model
(channels, stride) spec, validated against every model in presets.py.

By Axis previously had no model awareness at all — always assumed 4ch/8-stride
regardless of target model, silently wrong for every 16/128-channel model.
Gave it a model input (now last: primary_dim, reference, aspect_ratio,
batch_size, model), wired to the same spec table.

Both nodes now derive their model list/default from presets.py's own order
at module level instead of duplicating it — whichever model is listed first
in presets.py becomes the default everywhere, so a future architecture
doesn't need code changes elsewhere to become the default.

Also: rebuilt nodes.py/__init__.py/web extension from scratch (same node
IDs, same behavior — verified via smoke test) as a clean base for the above;
fixed two Flux.2 presets (1080 -> 1088) that weren't multiples of its
16-stride; added a 512x512 preset to every model for fast local iteration;
documented the By Axis model selector in README.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-14 19:45:11 +07:00
2025-06-07 19:54:50 +07:00
2025-06-07 19:54:50 +07:00
2025-06-07 19:54:50 +07:00

📐 CASNodes: Aspect Ratio Presets for ComfyUI

Unlock precision and convenience when generating empty latents for your favourite models in ComfyUI! CASNodes (Custom ASpect Ratio Nodes) lets you select popular aspect ratio and resolution presets—optimized for Krea, Flux.2, Qwen-Image, Flux.1, Stable Diffusion XL, and Stable Diffusion 1.5—or define your own by axis and ratio.


cas_aspect_ratio


✨ Features

  • Instant Dropdown Selection: Choose from a wide range of common image aspect ratios and sizes.

  • Supports Leading Models: Fully compatible with Krea, Flux.2, Qwen-Image, Flux.1, SDXL, and SD 1.5 — all locally-sampled diffusion models with a real ComfyUI LATENT/VAE pipeline.

  • Two Node Modes:

    • From Preset: Pick from curated model/ratio presets.
    • By Axis: Enter one dimension, pick aspect ratio, and auto-calculate the other.
  • Clean ComfyUI Integration: Appears under the standard latent category—no clutter, pure utility.


📦 Installation

  • Open ComfyUI
  • Go to Custom Node Manager
  • Search for comfyui-aspect-ratio-presets
  • Click Install

2. Manual (GitHub)

cd YOUR_COMFYUI/custom_nodes
git clone https://github.com/budihartono/comfyui-aspect-ratio-presets.git
  • Restart ComfyUI

🛠️ Usage

  1. Find your new nodes under the latent group:

    • CAS Empty Latent Aspect Ratio from Preset
    • CAS Empty Latent Aspect Ratio by Axis
  2. Preset Mode: Select a resolution and aspect ratio like:

    • 1024x1024 - 1:1 Square - SDXL
    • 912x512 - 16:9 Landscape - SD15
    • 1216x832 - 3:2 Landscape - Flux.1

    The output is a ready-to-use empty latent tensor, correctly sized for your model.

  3. By Axis Mode:

    • Enter a width or height.
    • Pick your aspect ratio (e.g., 3:2 Landscape).
    • Pick your model — the latent's channel count and spatial stride (e.g. Flux.2's 128ch/16x vs. the 16ch/8x used by Flux.1/Krea/Qwen-Image, or SD1.5/SDXL's 4ch/8x) are matched automatically.
    • The node calculates the matching dimension.

💡 Typical Workflow

graph LR
A[CAS Empty Latent Node] --> B(KSampler) --> C(VAEDecode) --> D(Output)
  1. Add a CASNodes latent node
  2. Connect it to KSampler (or any node needing a latent)
  3. Decode and save as usual!

📚 Supported Aspect Ratios & Models

  • All presets are tailored for leading models:

    • Krea
    • Flux.2
    • Qwen-Image
    • Flux.1
    • Stable Diffusion XL
    • Stable Diffusion 1.5
  • You can add your own in presets.py!


📝 Credits

Developed by @budihartono

Open source for the benefit of the community. Contributions are welcome, but please note: this project is provided as-is, and active support or responses to issues/pull requests may be limited or unavailable.


Enjoy supercharged workflows, perfectly matched to your favourite diffusion models!


S
Description
No description provided
Readme MIT
77 KiB
Languages
Python 84.3%
JavaScript 15.7%