Nodes/ComfyUI Seed Wildcard Pack/Resize Image by Base + Scale + Crop
ComfyUI Node

Resize Image by Base + Scale + Crop

Pixel-exact resizing with math you can read

By sinanzoo2nd·Created 8 months ago·Updated 3 months ago· 0
Resize Image by Base + Scale + Crop
  • image
  • IMAGE
resize_methodLanczos
base_width512
base_height512
scale1.00
cropfalse

Most resize nodes make you pick a target resolution or a percentage, and then the actual output size is whatever the interpolation math felt like. ResizeByScale ("Resize Image by Base + Scale + Crop") is the opposite: the output dimensions are a formula you can read straight off the node - base * scale - and it'll even crop back to the base for you. It's a utility node from the ComfyUI Seed Wildcard Pack that earns its keep in any workflow where exact dimensions matter.

What it's for

You use this when you want a consistent relationship between an image's base resolution and its working resolution. The classic case is a detail pass: take a 512×512 base, run it through a KSampler at 512×1.5 = 768×768, get a sharper result without guessing at a "nice" number. Or you're feeding a tile loop that needs every tile to land at a size the model handles well - you can reason about 1024×1.25 instead of eyeballing a dropdown.

It also makes batch behavior predictable. Because the math is base × scale, two runs with the same inputs always produce the same dimensions, which is more than you can say for percentage-based nodes that round differently.

How it works

Internally it's OpenCV doing the heavy lifting. For each image in the batch it computes:

  • new_width = int(base_width * scale)
  • new_height = int(base_height * scale)

then resizes with your chosen interpolation method. There's a floor of 16×16 baked in so a scale of 0.1 on a tiny base can't produce a dimension that blows up a convolution layer later.

The inputs that matter:

  • base_width / base_height - the anchor resolution (defaults 512×512)
  • scale - the multiplier, 0.1 to 10 (default 1.0)
  • resize_method - Lanczos (default), Bicubic, Bilinear, or Nearest. Lanczos is the right default for upscaling detail; switch to Bilinear/Nearest if you're downscaling or want a fast preview
  • crop - a boolean. When on, the node center-crops the scaled image back to base_width × base_height, which is how you get an exact target size even when the multiplier doesn't divide evenly. If the scaled image is smaller than the base, it skips the crop and warns you in the console

The single output, IMAGE, is a standard image tensor that feeds anything that takes an image - samplers, VAE encode, preview, whatever.

Where it sits in a workflow

The pattern that makes this shine is a resize → detail-pass loop: generate small, ResizeByScale up to a scale factor, run a low-denoise pass at the new resolution. You can also use it to normalize mixed-resolution inputs before a batch - every image comes out the same pixel math, which keeps batch behavior honest.

Install and dependencies

It ships in the ComfyUI Seed Wildcard Pack:

cd ComfyUI/custom_nodes
git clone https://github.com/sinanzoo2nd/ComfyUI-Seed-Wildcard-Pack

or search Seed Wildcard in ComfyUI Manager, then restart. Two things to know. First, there's no requirements.txt in the repo, so nothing gets auto-installed - this node imports cv2 (OpenCV) lazily, at execution time, not at import time. If you get an ImportError: cv2 the moment you queue a workflow, that's why:

pip install opencv-python

Most ComfyUI installs already have OpenCV from other dependencies, so you may never hit it. Second, one honest nit: the node prints a [DEBUG] Final tensor shape: line to the console on every run. Harmless, just noisy. That's the only quirk - it's otherwise a straight-ahead, no-surprises utility.

Gotchas

  • crop only trims down. If your scaled result is smaller than the base, it does nothing (and tells you in the console). Size your base and scale so the scaled result is bigger if you intend to crop.
  • The output is a plain IMAGE - there's no latent variant, so if you want to keep things in latent space, resize before VAE encode.
  • Don't expect anything fancy from this node; that's the point. It's one formula, done right, with no hidden state.
Categoryimage/resize

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
resize_methodCOMBOLanczos4 options: Lanczos, Bicubic, Bilinear, Nearest
base_widthINT5120–4096
base_heightINT5120–4096
scaleFLOAT1.000.1–10
cropBOOLEANfalse

Outputs (1)

NameTypeDescription
IMAGEIMAGE