D2 Resize Calculator
Upscale math that stays a multiple of 8, because your VAE will thank you
- width
- height
- rescale_factor
Resize Calculator exists because "1024 × 2" isn't 2048 when diffusion is involved - it's "whatever multiple of 8 is nearest 2048," because your VAE wants latent dimensions that divide cleanly. This node takes a width, a height, and a scale factor, and hands you back dimensions you can feed straight into an Empty Latent without crossing your fingers.
If you've built a hi-res fix or img2img upscale workflow by hand, you've had the moment where the output comes out slightly off because 2048 × 1.5 = 3072, which is divisible by 8, but 1024 × 1.75 = 1792... which actually is fine, and 1000 × 2 = 2000, which isn't. The manual version of this is "round to the nearest 8 in your head." This node is that, in node form, with the rounding method exposed.
The inputs and outputs
width/height- the source dimensions (defaults 1024 × 1024).rescale_factor- the multiplier, from 0.1 to 16 (default 2.0).round_method- how to snap the result:Round(nearest multiple of 8),Floor(down),Ceil(up), orNone(leave as-is).
Outputs are width, height, and rescale_factor (passed through). The math is simply int(dim * factor) then snapped to a multiple of 8 per your rounding method.
Why multiples of 8?
The latent space is 8× downsampled, so the encoder/decoder works on width // 8 and height // 8. If your image dimensions don't divide by 8, you get misalignment or a baked-in error - usually a small one, but one that compounds in a multi-pass workflow. Rounding to a multiple of 8 before encoding is cheap insurance, and it's the single habit that fixes the vague "edges look slightly off" class of problems.
The Floor option is the one most people end up on. Round picks the nearest multiple, which can land above your target; if you're memory-constrained and want to guarantee you never exceed the nominal size, Floor gives you the nearest multiple at or below it. Use None only when you know the downstream node handles arbitrary dims (some img2img upscale chains don't care).
Installing
Part of the D2-nodes-ComfyUI pack - install the pack, not the node.
- ComfyUI Manager → search "D2-nodes-ComfyUI" → Install → restart.
- Or
cd ComfyUI/custom_nodes && git clone https://github.com/da2el-ai/D2-nodes-ComfyUIand restart.
Dependencies: piexif, charset-normalizer - nothing heavy, no model downloads. Pack gotcha: v32.0.0+ needs the ComfyUI V3 schema; older ComfyUI → use a pre-32.0.0 release. Also delete the old standalone ComfyUI-d2-size-selector pack if you have it.
When you'd actually reach for it
In a hi-res fix chain: base sampler at 1024 → upscale 1.5× → second pass. Drop Resize Calculator between the two with rescale_factor = 1.5 and round_method = Floor, and feed its width/height into the empty latent for the second pass. It replaces the fiddly ImageScale + manual math you'd otherwise write. It's a tiny node, but it's the kind that quietly prevents a whole class of "why is my second pass slightly misaligned" threads.
One honest caveat: it's a pure calculator. If you need to also apply the resize to an actual image, that's the pack's D2 Image Resize (which can even call upscale models). Pair them and you've got a tidy upscale block.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 102464–8192 | — |
| height | INT | 102464–8192 | — |
| rescale_factor | FLOAT | 2.0000.1–16 | — |
| round_method | COMBO | Round | 4 options: Floor, Round, Ceil, None |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| rescale_factor | FLOAT | — |