Nodes/RC Image Compositor/RC Canvas Resize
ComfyUI Node

RC Canvas Resize

Grow the canvas, keep the image — without math

By kj863257·Created 11 months ago·Updated 10 months ago· 16
RC Canvas Resize
  • image
  • IMAGE
new_width512
new_height512
anchorcenter
x_offset0
y_offset0
background_color_r0.00
background_color_g0.00
background_color_b0.00

Resizing an image and resizing a canvas are two completely different operations, and the difference matters constantly in compositing. Scaling the image squishes your pixels. Growing the canvas adds space around them - which is exactly what you need when you want room for a watermark, a caption bar, a drop shadow, or a second image to composite against. RC Canvas Resize is the latter: it resizes the canvas and repositions the existing image inside it, leaving the pixels untouched.

It's a utility from the RC Image Compositor pack, and once you've used it once you'll keep finding excuses for it.

How it works

You give it a new canvas size and an anchor position, and the node places the original image at that anchor, filling the rest with a solid background color. The clever bit is the anchor system - nine positions (center, all four corners, all four edges) plus independent X and Y pixel offsets, so you can reliably park an image at, say, top-left with a 50px margin without doing any coordinate arithmetic in your head.

Background color is set with three floats (r, g, b), each 0–1. Default is black, which is a trap if you forget to change it - a black matte behind a bright image looks broken until you realize it's the fill color.

The inputs that matter

  • image - the input tensor.
  • new_width / new_height - target canvas size in pixels (64–8192).
  • anchor - where the original image sits in the new canvas: center, top_left, top_center, top_right, middle_left, middle_right, bottom_left, bottom_center, bottom_right.
  • x_offset / y_offset - fine-tune in pixels, can be negative.
  • background_color_r/g/b - the fill color, 0–1 floats. Black by default.

Output is a single IMAGE tensor with the new dimensions.

How to install it

Ships with the RC Image Compositor pack:

cd ComfyUI/custom_nodes
git clone https://github.com/kj863257/ComfyUI_RC_Image_Compositor
cd ComfyUI_RC_Image_Compositor
pip install -r requirements.txt

Restart ComfyUI, or install via ComfyUI Manager by searching "RC Image Compositor". Just pillow, numpy, and opencv-python - no models.

Common issues

The first stumble is confusing this with scaling. If you set new dimensions smaller than the image, the image gets cropped, not squished - the canvas shrinks around the anchor point. That's the intended behavior; if you wanted to downscale, use RC Image Scale instead.

The second is the solid-color background. Unlike the pack's RC Canvas Padding node, which offers edge/mirror/transparent fills, Canvas Resize only does flat color. For transparent padding you'll want RC Canvas Padding with fill_mode=transparent. And remember the color floats are 0–1, not 0–255 - typing 255 for white gives you a clamped 1.0, which happens to work, but typing 128 expecting mid-gray gives you pure white. Keep it in 0–1 and you're fine.

CategoryRC/Utilities

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
new_widthINT51264–8192New canvas width
new_heightINT51264–8192New canvas height
anchorCOMBOcenterImage anchor position in new canvas: - center: Center - top_left: Top-left corner - top_center: Top center - top_right: Top-right corner - middle_left: Middle left - middle_right: Middle right - bottom_left: Bottom-left corner - bottom_center: Bottom center - bottom_right: Bottom-right corner
x_offsetINT0-4096–4096Additional X offset (pixels)
y_offsetINT0-4096–4096Additional Y offset (pixels)
background_color_rFLOAT0.000–1Background color red component
background_color_gFLOAT0.000–1Background color green component
background_color_bFLOAT0.000–1Background color blue component

Outputs (1)

NameTypeDescription
IMAGEIMAGE