Auto-Size 64 (MP)
Pick a megapixel budget, get 64-safe dimensions back
- image
- width
- height
- dims_json
SDXL was trained near one megapixel, and every half-decent guide tells you to keep the long side on the 64 grid - 1024×1024, 1216×832, 1344×768, that family. Doing that math by hand for every aspect ratio is where you end up with 1034×774 and an image that looks subtly squished. Auto-Size 64 (MP) collapses the whole thing into one dropdown: pick a target megapixel budget, it hands you back width and height snapped to 64-multiples. It's the "Auto-Size 64 (MP)" node in the SDXL Adherence pack (regiellis/ComfyUI-SDXL-Adherence).
It's a helper, not a headliner - the kind of node you drop in when you're tired of typing numbers or when you're building a workflow someone else will use.
How it works
The size control is a target megapixel figure: Auto, 1.0MP, 1.5MP, or 2.0MP. The fun bit is what Auto does: it sniffs your VRAM with torch.cuda.get_device_properties, and picks 1.0 MP on cards under 10 GB, 1.2 MP under 18 GB, and 1.5 MP above that. So "Auto" is really "the size your card can chew through without drama," not "the sharpest possible." Pick a fixed MP if you want quality to win.
Aspect ratio comes from the optional image input - drop a reference image in and it keeps that image's W/H. No image means it assumes square. From there it's one line of algebra: W = sqrt(megapixels * aspect), H = megapixels / W, then both are floored to the nearest 64.
Inputs and outputs
size- Auto / 1.0MP / 1.5MP / 2.0MP. The one you'll actually touch.image(optional) - just for inferring aspect ratio. Ignore it and you get a square.
Outputs are width and height (two INTs to feed your latent node) plus dims_json, a STRING with {W, H, mp, size} for debugging or metadata.
Installing it
It lives in the SDXL Adherence pack, so one install gets you all seven nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/regiellis/ComfyUI-SDXL-Adherence
Restart ComfyUI, or grab it via ComfyUI Manager by searching "SDXL Adherence". No models to download, no extra dependencies.
Where it fits
In the pack's own usage diagram, Auto-Size 64 sits upstream: Image → Auto-Size 64 → Smart Latent. Wire its width/height into Smart Latent (which has its own resolution presets too, if you prefer those) or into a plain Empty Latent, and you get a workflow that stays sane when the input image changes aspect.
The one gotcha
It floors to 64, so you'll usually land a hair under your target megapixels - 1.0 MP often resolves to something like 0.99. That's by design, not a bug; undershooting is safer than overshooting on the grid. And remember Auto picks by VRAM, so if your card is beefy but your patience isn't, set 2.0MP and watch the sampler work for it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| size | COMBO | Auto | Target megapixels (snapped to 64). |
| imageopt | IMAGE | Optional image to infer aspect ratio. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| dims_json | STRING | — |