Nodes/DOGMA Nodes/DOGMA ScaleFactor v1.0.11
ComfyUI Node

DOGMA ScaleFactor v1.0.11

The one-number answer to \"how much did I scale this?\"

By axior·Created 6 months ago·Updated 16 days ago· 2
DOGMA ScaleFactor v1.0.11
  • image
  • original
  • factor

A mask is only valid at the resolution it was made at. The moment you upscale a render - or run a phase at 4K and composite into a 6K master - every mask you built in the previous phase is at the wrong scale, and handing a 2048-wide mask to a 6144-wide image doesn't error. It just silently masks the wrong part of the frame.

This node exists to make that arithmetic explicit. Two images in, one float out:

factor = image_width / original_width

Wire the scaled image into image, the pre-scale original into original, and factor tells you exactly how much bigger you got. Width only - the pack's phases scale proportionally, so width is the honest measure and using it avoids surprises when one dimension rounds to a multiple of 32 and the other doesn't.

The inputs and outputs

  • image (IMAGE) - the scaled version.
  • original (IMAGE) - what it was before.
  • factor (FLOAT) - the ratio. 1.0 means nothing happened; 2.0 means double.

That's the entire node, and yes, you could compute it in a math node. But the pack's resize helpers use round(x/32)*32 on each axis, so the ratio is rarely the round number you typed - "upscale to 4096" on a 1920-wide source lands you at 2.1333…, not 2. Feeding that into a mask rescale step is exactly the sort of thing that produces a mask half a percent off and a visible seam on one edge.

Install

Manager → search DOGMA Nodes, or:

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

Restart. No dependencies beyond ComfyUI itself; the pack's only pip install is scipy>=1.10, which this node doesn't touch.

Using it well

The useful pattern is to keep the factor in the graph rather than in your head: compute it once after the render phase, then feed it wherever a mask or a crop needs to come back into the master's coordinate space. The pack's own crops and stitches do this internally, but when you're wiring a third-party upscaler or a detail pass into a DOGMA phase, this node is the adapter.

One caveat: it measures what actually happened, not what you intended. If a resize silently padded instead of scaling - which the pack's fit helpers do when the source is small - you'll get a factor that isn't the one your resize settings suggest, and that's the node doing you a favour.

And if you're feeding factor into a node that expects a scale to apply, remember which direction you're going: this is the ratio of output to input, so to bring masks back to the original resolution you divide by it, not multiply. Getting that backwards produces a mask that slides off the object it was made for - visually confusing in a way that costs an hour if you don't check the numbers first.

CategoryDOGMA/v1.0.11

Inputs (2)

NameTypeDefaultDescription
imageIMAGE—
originalIMAGE—

Outputs (1)

NameTypeDescription
factorFLOAT—