Nodes/ComfyUI_yanc/๐Ÿ˜ผ> Scale Image to Side
ComfyUI Node

๐Ÿ˜ผ> Scale Image to Side

Resize by 'make the long edge 1024' instead of fighting width/height math

By ALatentPlaceยทCreated 2 years agoยทUpdated 2 years agoยท 80
๐Ÿ˜ผ> Scale Image to Side
  • image
  • mask_opt
  • image
  • mask
  • width
  • height
  • scale_ratio
โ—„scale_to512โ–บ
โ—„sideโ–พโ–บ
โ—„interpolationโ–พโ–บ
โ—„modulo0โ–บ

Vanilla ComfyUI resize nodes want you to specify width and height explicitly, which means doing the aspect-ratio math yourself every time you load an image of unknown dimensions and just want "make the longest side 1024, keep proportions." Scale Image to Side does that job directly: pick which side you care about (width, height, shortest, or longest) and a target number, and it scales the whole image proportionally to hit it.

This is the node you reach for right after loading an arbitrary reference or ControlNet source image, before it goes anywhere near a sampler. A lot of preprocessors and upscalers care about being fed dimensions divisible by 8 or 64 - that's what the modulo input is for.

How it works

It measures your image, figures out the current value of whichever side you picked, and scales the entire image by the ratio needed to bring that side to scale_to, using your chosen interpolation method. If a modulo other than 0 is set, it nudges the final dimensions to the nearest multiple of that number - useful for keeping outputs SDXL/VAE-friendly (multiples of 8) or matching a specific model's requirements.

The inputs and outputs that matter

  • image - the IMAGE to resize.
  • scale_to (INT, default 512) - the target size for whichever side you pick.
  • side - shortest, longest, width, or height. longest is the common choice for "cap this image's largest dimension" regardless of orientation; shortest is what you want feeding into a center-crop step.
  • interpolation - lanczos, bilinear, bicubic, nearest, nearest-exact, or area. Lanczos is the default sane choice for photographic content; nearest/nearest-exact only really make sense for pixel art or masks where you don't want smoothing.
  • modulo (INT, default 0) - rounds the resulting dimensions to a multiple of this. Set it to 8 (or 64 for some models) if downstream nodes complain about odd dimensions.
  • mask_opt (optional MASK) - if you're resizing an image alongside its mask, feed the mask in here and it gets resized in lockstep, so you don't have to run a second resize node and risk the two drifting out of sync.

Outputs: image, mask (the resized mask if you supplied one), width, height, and scale_ratio (FLOAT) - the exact factor applied, handy if you need to scale something else (like coordinates from a detection node) by the same amount downstream.

How to install it

Via ComfyUI Manager: search "yanc" or "YANC - Yet Another Node Collection," install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ALatentPlace/ComfyUI_yanc

then restart. No extra dependencies or model downloads.

Common issues & troubleshooting

Output dimensions aren't exactly your target number. That's the modulo setting doing its job - if you set it to 8, the final size gets rounded to the nearest multiple of 8, which can land a pixel or few off your literal scale_to value. If you need the exact number, set modulo to 0.

Upscaling a small image looks soft or blocky. This is a straightforward interpolation resize, not an AI upscaler - pushing a small image up several times its size with Lanczos or bicubic will look noticeably softer than a proper ESRGAN-style upscale. Use this node for downscaling and modest resizes; reach for a dedicated upscale model when you're scaling up significantly.

Mask and image end up different sizes. Only happens if you resize the image here but resize the mask through a different node elsewhere - always route the mask through mask_opt on this same node so both scale by the identical ratio.

CategoryYANC/๐Ÿ˜ผ Image

Inputs (6)

NameTypeDefaultDescription
imageIMAGEโ€”
scale_toINT512โ€”
sideCOMBO4 options: shortest, longest, width, height
interpolationCOMBO6 options: lanczos, nearest, bilinear, bicubic, area, nearest-exact
moduloINT0โ€”
mask_optoptMASKโ€”

Outputs (5)

NameTypeDescription
imageIMAGEโ€”
maskMASKโ€”
widthINTโ€”
heightINTโ€”
scale_ratioFLOATโ€”