Nodes/ComfyUI-NunchakuFluxLoraStacker/ControlAltAI: Megapixel Calculator
ComfyUI Node

ControlAltAI: Megapixel Calculator

Stop hand-typing width/height for FLUX

By ussoewwin·Created 10 months ago·Updated about a month ago· 18
ControlAltAI: Megapixel Calculator
    • width
    • height
    • resolution
    • preview
    megapixel1.0
    aspect_ratio1:1 (Perfect Square)
    divisible_by64
    custom_ratiofalse
    custom_aspect_ratio1:1

    Small utility, does one thing, and it's a thing you'll actually use every session once you've got it: pick a target megapixel count and an aspect ratio, and it hands you back a width and height that are both correct for that ratio and divisible by whatever your model needs. FLUX in particular wants dimensions divisible by 64, and eyeballing that math while also hitting a specific aspect ratio and megapixel budget is exactly the kind of arithmetic nobody wants to do by hand for the twentieth time.

    It's not from this pack's own author originally - it's part of the ControlAltAI Nodes family (upstream gseth/ControlAltAI-Nodes, MIT licensed), which the pack maintainer forked for Python 3.13 compatibility and merged in here rather than keeping a separate repo. That's worth knowing mainly so you're not surprised to see "ControlAltAI Nodes/Flux" as this node's category instead of anything Nunchaku-branded - it's along for the ride, not tied to the quantization stuff the rest of the pack focuses on.

    The inputs are all dropdowns and one boolean. megapixel picks your target size (0.1 up through roughly 2.5 in the built-in list, defaulting to 1.0 - the FLUX/SDXL sweet spot). aspect_ratio is a long preset list - square, classic portrait, golden ratio, ultra-tall, and so on - each one carrying a friendly name so you're not guessing what "9:19" looks like. divisible_by constrains the output dimensions to a multiple of 8, 16, 32, or 64; default is 64, which is the safe choice for FLUX specifically (concepts.md's own numbers: FLUX wants "1024x1024+, flexible, must be divisible by 64" - this node exists to enforce exactly that constraint without you doing the division in your head). If none of the presets fit what you're after, flip custom_ratio on and type your own into the optional custom_aspect_ratio field (e.g. 21:9).

    Outputs: width and height as plain integers, ready to wire straight into an Empty Latent Image node (or anywhere else that wants explicit dimensions). resolution gives you the same thing as a formatted string, handy if you want it in a text overlay or a filename. preview outputs an IMAGE - a blank canvas at the computed dimensions, so you can drop it into a Preview Image node and actually see the aspect ratio and rough size before you spend GPU time generating anything at that resolution.

    Installing it: bundled with the pack, no separate step - through ComfyUI Manager, search "ComfyUI-NunchakuFluxLoraStacker," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ussoewwin/ComfyUI-NunchakuFluxLoraStacker.git
    

    Restart ComfyUI and it'll show up under the ControlAltAI Nodes category.

    Common trip-up: matching a manual EmptyLatentImage node's width/height to what you think this node computed, instead of actually wiring the width/height outputs into it - if you retype the numbers by hand you'll eventually introduce a typo that isn't a multiple of your divisible_by setting, which defeats the entire point of using this node in the first place. Wire it, don't copy it. Beyond that there's not much to break here: it's pure arithmetic with no model dependency, so if the numbers look wrong the first thing to check is which divisible_by value you actually left selected, since 64 vs 8 can shift a computed dimension by a surprising amount at small megapixel counts.

    CategoryControlAltAI Nodes/Flux

    Inputs (5)

    NameTypeDefaultDescription
    megapixelCOMBO1.025 options: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, +19
    aspect_ratioCOMBO1:1 (Perfect Square)23 options: 1:1 (Perfect Square), 2:3 (Classic Portrait), 3:4 (Golden Ratio), 3:5 (Elegant Vertical), 4:5 (Artistic Frame), 5:7 (Balanced Portrait), +17
    divisible_byCOMBO644 options: 8, 16, 32, 64
    custom_ratioBOOLEANfalse
    custom_aspect_ratiooptSTRING1:1

    Outputs (4)

    NameTypeDescription
    widthINT
    heightINT
    resolutionSTRING
    previewIMAGE