Nodes/ComfyUI-Addoor/Width and height for scaling image to ideal resolution 🪴
ComfyUI Node

Width and height for scaling image to ideal resolution 🪴

Fit any image to the model's sweet spot

By Eagle-CN·Created 2 years ago·Updated about a year ago· 75
Width and height for scaling image to ideal resolution 🪴
  • image
  • width
  • height
target_size1024
multiple_of8

The sibling of the aspect-ratio picker, but for when you already have an image. You feed it a picture, it reads the shape, and it tells you the width and height to scale that picture to so it lands near your model's happy resolution - without stretching it out of proportion. It doesn't resize anything itself. It does the arithmetic; a resize node does the work.

When you reach for it

Img2img and inpainting, mostly. Someone hands you a 3000×2000 photo and you want to run it through an SDXL or Flux workflow. Feed that straight in and you're way above the model's native resolution, which is exactly where the community's "too big" artifacts live - duplicated features, mangled anatomy, tiling. But you also can't just squash it to 1024×1024, because now everyone's face is wrong.

What you actually want is: keep the original aspect ratio, but rescale so the resolution sits around where the model was trained. This node computes those two numbers for you off the image itself.

The inputs

  • image - the picture you want to fit. It only reads the dimensions; the pixels pass by untouched.
  • target_size - the resolution you're aiming for (default 1024). Set it to your model's native size.
  • multiple_of (optional) - snaps the result to a multiple of this, default 8, because latent dimensions have to divide by 8. Nudge to 16/64 for fussier models.

It outputs width and height as integers. Those go into your resize node (an Upscale Image / Image Resize), and that's what actually rescales the picture. Then the properly-sized image goes into your VAE encode or your workflow proper.

The mental model

Think of it as a measuring tape, not scissors. It looks at "this image is 3:2 and huge," decides "at target 1024 that's 1216×832-ish, snapped to 8," and reports back. You still need a resize node downstream to cut to those numbers. Pairing it with a good resize (Lanczos for the downscale - it's clean and doesn't invent anything) gives you an input that's the right size and the right shape, which is half the battle in img2img quality.

The 🪴 marks it as one of the community utility nodes bundled into ComfyUI-Addoor rather than one of the author's own AD_ nodes.

Installing ComfyUI-Addoor

Through ComfyUI Manager: Install Custom Nodes → search "ComfyUI-Addoor" → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/Eagle-CN/ComfyUI-Addoor.git
cd ComfyUI-Addoor
pip install -r requirements.txt

Restart; it's under 🌻 Addoor / Utilities. Remember it's a calculator, not a resizer - if you wire the outputs somewhere and nothing changes size, that's because you still need an actual resize node between this and your model.

Category🌻 Addoor/Utilities

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
target_sizeINT102464–8192
multiple_ofoptINT81–1024

Outputs (2)

NameTypeDescription
widthINT
heightINT