Nodes/ComfyUI-RyuuNoodles/Scale To Multiple 🐲
ComfyUI Node

Scale To Multiple 🐲

Snap your image sizes to a clean multiple so the latent doesn't silently hate you

By DraconicDragonΒ·Created about a year agoΒ·Updated 2 months agoΒ· 12
Scale To Multiple 🐲
  • image
  • scaled_image
  • scaled_width
  • scaled_height
β—„multiple64β–Ί
β—„crop_modestretchβ–Ί
β—„resize_modelanczosβ–Ί
β—„rounding_modenearestβ–Ί
β—„scale_factor1.000β–Ί
β—„widthβ€”β–Ί
β—„heightβ€”β–Ί

Every diffusion model has a native resolution and a set of dimensions it wants to see. SDXL likes multiples of 64 and roughly a megapixel; video models want multiples of 16 or 32; generate off-grid and you get duplicated anatomy, tiling, or a latent that refuses to cooperate. Scale To Multiple is the node that makes your numbers and your images agree: it snaps a width/height (or a whole image) to the nearest multiple you specify.

What it does

Give it a multiple (default 64), and it rounds a width and height up or down to a multiple of that value. The clever part is it works with or without an image:

  • With an image - it scales the image to the snapped dimensions.
  • Without an image - it just does the math and outputs the numbers, plus a placeholder image so the graph stays wired.

That second mode is the sleeper feature. Wire the scaled_width and scaled_height outputs straight into a KSampler or latent node and you've got a pure arithmetic helper: "whatever the workflow says, make it a multiple of 64."

If you supply the optional width and/or height inputs, those act as overrides - the image gets scaled to those values (snapped to the multiple) instead of its own dimensions. No image plus overrides = pure number scaling. That's the whole input matrix, and it's flexible without being fiddly.

The controls that matter

  • multiple - the snap target. Default 64 (the SDXL sweet spot); set to 1 to effectively disable it.
  • rounding_mode - nearest (default), floor, or ceil. Floor matters when you're feeding a VRAM-strapped latent and want to guarantee you never exceed a budget; ceil when you need minimum coverage.
  • crop_mode - how the image fills the target box: stretch, center, fill (scale + crop), uniform (fit inside), or uniform fill (fit with padding).
  • resize_mode - lanczos is default and the right call for downscaling. There's also bilinear - tensor, which uses torch.nn.functional.interpolate() and looks noticeably different from PIL's bilinear - worth knowing if you've ever seen the same mode render differently between two node packs.
  • scale_factor - multiply width and height by this before snapping. Handy for pre-scaling a hires pass.

Outputs

  • scaled_image - the resized image.
  • scaled_width / scaled_height - the integers. The image-independent mode is where these shine.

Installing it

Same pack, same command:

cd ComfyUI/custom_nodes
git clone https://github.com/DraconicDragon/ComfyUI-RyuuNoodles

Restart or use ComfyUI Manager (search "RyuuNoodles"). No models, no extra deps beyond the pack's color-matcher requirement which this node never touches.

Gotchas

Two things. First: if image, width, and height are all left unconnected, the node raises a ValueError - it needs at least one source of truth. Second: when you run it image-less, the placeholder it outputs is a black image with the text "No Image" drawn on it. That's a stand-in so the graph stays connected, not something to save. It's easy to forget and accidentally save a black PNG if you're routing the image output onward without checking. Beyond that, if your workflow runs through this node a lot and the console logs about "using image width" annoy you, the pack's settings page has a log-level control.

CategoryRyuuNoodles 🐲/Images

Inputs (8)

NameTypeDefaultDescription
multipleINT64Multiple to scale to. Setting to 1 effectively disables this.
crop_modeCOMBOstretchCrop mode for the image. 'stretch' will stretch the image to fill the target dimensions. 'center' will center the image in the target dimensions. 'fill' will scale the image to fill the target dimensions while maintaining aspect ratio, cropping if necessary. 'uniform' will scale the image to fit within the target dimensions while maintaining aspect ratio. 'uniform fill' will scale the image to fill the target dimensions while maintaining aspect ratio, adding padding if necessary.
resize_modeCOMBOlanczosResize mode for the image. 'bilinear - tensor' is different from normal bilinear, it will use torch.nn.functional.interpolate() to resize the image and look very different from normal bilinear.
rounding_modeCOMBOnearestRounding mode for both width and height. 'nearest' will round to the nearest multiple of 'multiple' value. 'floor' will round down to the nearest multiple. 'ceil' will round up.
scale_factorFLOAT1.000How much to multiply both width and height by before scaling to multiple.
imageoptIMAGEImage to scale. If not provided, only width and height will be scaled. If either or both of the optional width/height inputs are provided, the resizing will use the given input(s).
widthoptINTOptional width to scale the image to after the multiple scaling. If no image is provided it will still output the scaled number.
heightoptINTOptional height to scale the image to after the multiple scaling. If no image is provided it will still output the scaled number.

Outputs (3)

NameTypeDescription
scaled_imageIMAGEβ€”
scaled_widthINTβ€”
scaled_heightINTβ€”