Nodes/antrobots ComfyUI Nodepack/Scale Image with Reference
ComfyUI Node

Scale Image with Reference

Resize one image to match another

By antrobot1234·Created 3 years ago·Updated about a year ago· 28
Scale Image with Reference
  • image_in
  • image_ref
  • image_out
scale_modebilinear

Scale Image with Reference resizes one image to match the dimensions of another. You give it the image you want to resize and a second image to copy the size from, and it scales the first to the second's width and height. No typing numbers, no math - the reference image is the target size. It's the node you want whenever two images have to line up and you don't know (or don't want to hardcode) the exact pixel dimensions.

The classic use is compositing. To paste or blend one image onto another, they usually need to be the same size first - so you feed your source as the image to scale and your destination as the reference, and now they match. Same story when an upscaler or a different-resolution branch produced something that no longer fits its partner: scale it back to a reference and everything downstream aligns. It saves you from chasing dimension mismatches by hand.

How it works

It reads the width and height of the reference image and resizes the input image to those exact dimensions using the interpolation method you pick. Note it matches the reference's dimensions outright - if the two images have different aspect ratios, the input gets stretched to fit rather than cropped or padded, so it's happiest when the shapes already roughly agree.

The inputs and outputs that matter

  • image_in (required) - the image to resize.
  • image_ref (required) - the image whose dimensions you're matching. Its pixels aren't used, only its width and height.
  • scale_mode (optional, default bilinear) - the interpolation. bilinear is the smooth all-rounder and a fine default. bicubic is a touch sharper (can faintly ring on edges). nearest and nearest-exact do no blending at all - use those for pixel art or when scaling mask-like images where you don't want new in-between values.

One output: image_out, the resized IMAGE, now the same size as the reference.

Installing it

Lightweight pure-Python pack - no weights, no heavy deps. ComfyUI Manager → Install Custom Nodes → search "antrobots ComfyUI Nodepack" → Install → restart, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/antrobot1234/antrobots-comfyUI-nodepack

then restart. It's under antrobots-ComfyUI-nodepack/image-handling.

Common issues

The aspect-ratio thing is the main gotcha. Because it matches the reference's dimensions exactly, feeding it two images of different proportions stretches or squashes the input to fit - a portrait scaled to a landscape reference comes out distorted. If your images don't share an aspect ratio, resize with intent (crop or pad to the right shape first) rather than expecting this node to handle it gracefully.

Pick the scale_mode to suit the content: leaving it on bilinear for a mask or a pixel-art sprite introduces soft in-between values you probably don't want, so switch to nearest there. For ordinary photographic images, bilinear or bicubic is right. As with the rest of this small solo pack, a genuine bug is best reported as a GitHub issue - the author asks for them in the README.

Categoryantrobots-ComfyUI-nodepack/image-handling

Inputs (3)

NameTypeDefaultDescription
image_inIMAGE
image_refIMAGE
scale_modeoptCOMBObilinear4 options: nearest, nearest-exact, bilinear, bicubic

Outputs (1)

NameTypeDescription
image_outIMAGE