Nodes/DOGMA Nodes/DOGMA FitDimensions32 v2
ComfyUI Node

DOGMA FitDimensions32 v2

Resolution math that never hands the VAE an illegal number

By axior·Created 6 months ago·Updated 16 days ago· 2
DOGMA FitDimensions32 v2
  • image
  • width
  • height
◄long_side3840►

What it is

A two-integer calculator with a picture attached. Give it any image and a target long side, and it returns a width and a height that preserve the aspect ratio and land on multiples of 32 - the numbers you can safely hand to an Empty Latent Image node without the VAE politely telling you your dimensions don't divide.

That's it. It's the least dramatic node in the pack and one of the few that saves you a whole class of annoyance.

How it computes

Straight from the source:

w = max(32, round(long_side * w / max(h, w) / 32) * 32)
h = max(32, round(long_side * h / max(h, w) / 32) * 32)

Worth noticing two things. It uses round(), not floor(), so both edges can drift by up to 16 pixels from a perfect aspect match - a 1000×999 source at long_side=3840 comes back as 3840×3840, not 3840×3836. And it's driven by the actual image tensor, not by a width/height you typed, which means it re-computes correctly when you drop a different file into the loader above it. No re-typing, no stale numbers.

When you'd reach for it

The obvious case is a resize step: source image in, long_side set to your target, wire width/height into a latent or a resize node. The reason it exists in this pack is a bit more specific - the DOGMA pipeline works at native resolution and refuses to downscale crops, so the numbers it needs are "as close to the source as possible, but legal." That's what the multiple-of-32 rounding is for.

The 32 specifically: VAEs downsample by 8, so 32 is quietly generous for SD-family models, and it's the safety margin you want when a model or a node does an extra tiling pass. Some families are fussier than others - the troubleshooting doc's resolution table flags Flux as wanting multiples of 64 - so treat 32 as the safe floor, not the whole story. If a node is complaining at you about divisibility, going to 64 costs you a few pixels and removes the question.

Two habits worth keeping:

  • Find the resolution you want, then check it against your VRAM. The default long_side here is 3840, which is 4K long side. That's the pack's own restoration target and it is not a beginner default - on a 12GB card you'll want 1024–2048 for a first run, then climb.
  • Round-trip it through an integer pair, not a scale factor. A scale float of 1.5 on an odd source is how you get 1215×807 and a weird error three nodes later.

Inputs and outputs

  • image (IMAGE) - any image tensor; only its H/W is used, nothing is modified and nothing is rendered.
  • long_side (INT, 32–16384, step 32, default 3840) - the target for whichever edge is longer. A portrait source gets its height set to this, a landscape source its width.

Outputs:

  • width (INT) and height (INT) - wire them into Empty Latent Image, or into any resolution/upscale node that takes explicit dimensions. Both are already legal multiples of 32, so nothing downstream needs to re-round them (and nothing downstream should, or you can drift back off-grid).

Note the minimum is 32 on both edges, so an extreme panorama at a small long_side will come out letterboxed to at least 32 on the short edge rather than collapsing to zero. That's a guard against a degenerate tensor, not a design feature - if you're seeing 32 on an edge, your aspect maths is the actual problem.

Install

Manager → search DOGMA Nodes (publisher axior), or:

cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI

requirements.txt declares scipy>=1.10 as the pack's only Python dependency; this node itself is pure arithmetic and imports nothing outside ComfyUI's image tensors. No model files, no core patches.

Honest note on value: there are half a dozen resolution nodes in the ecosystem that do this - most of the big utility packs ship one, and ComfyUI itself will snap dimensions in a few places these days. You'd grab this one if you're already inside a DOGMA pipeline and want the same rounding rules as the crop nodes (which also pad to 32, for the same reason). It does not do anything clever beyond that, and this article is not going to pretend otherwise.

CategoryDOGMA/v2

Inputs (2)

NameTypeDefaultDescription
imageIMAGE—
long_sideINT384032–16384—

Outputs (2)

NameTypeDescription
widthINT—
heightINT—