Nodes/ComfyUI-RMBG/Image Resize (RMBG) 🖼️🎭
ComfyUI Node Runs on cloud

Image Resize (RMBG) 🖼️🎭

Image Resize (RMBG)

By 1038lab·Created 2 years ago·Updated 8 days ago· 2,051
Image Resize (RMBG) 🖼️🎭
  • image
  • pad_color
  • mask
  • IMAGE
  • MASK
  • WIDTH
  • HEIGHT
custom_width0
custom_height0
megapixels0.00
scale_by1.00
resize_modelongest_side
resize_value0
upscale_methodlanczos
devicecpu
divisible_by2
output_modestretch
crop_positioncenter

Image Resize is a do-everything resize node - and if you've fought with ComfyUI's scattered scaling nodes, the appeal is that it folds all the common resize behaviors into one box. Scale by a factor, hit an exact size, target a megapixel count, pad to an aspect ratio, crop to fit, force divisibility for a model that demands multiples of 8 - it's all here. For prepping images before a background remover or fitting a result into a fixed canvas, this is a genuine time-saver.

It's a pure image-processing node, no model. What makes it more than a basic scaler is output_mode, which decides what happens when your target shape doesn't match the image's aspect ratio. stretch (the default) just squashes it to fit - fast, but distorts. pad, pad_edge, and pad_edge_pixel add borders instead (with pad_color setting the fill), keeping the image undistorted inside a fixed frame. crop cuts to fit without distortion, and crop_position (center, top, bottom, left, right) picks which part you keep. pillarbox_blur is the nice one - it fills the empty space with a blurred, stretched copy of the image instead of a flat color, the letterbox trick you see in social video. Choosing the right mode here is the difference between a warped subject and a clean fit.

The sizing inputs give you several ways to say how big: custom_width / custom_height for exact dimensions, scale_by for a multiplier, megapixels for a total pixel budget, or resize_mode (longest_side / shortest_side) plus resize_value to pin one dimension. upscale_method sets the filter (lanczos default for sharp results). divisible_by (default 2) rounds the output to a multiple you choose - set it to 8 or 64 when a downstream model is picky about dimensions, which saves the classic "tensor size mismatch" error. device runs the resize on CPU or GPU. There's an optional mask input that gets resized right alongside the image, so a mask and its picture stay aligned. Outputs are IMAGE, MASK, WIDTH, and HEIGHT.

Install comes with the pack: "Comfyui-RMBG" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt and restart. Nothing to download.

Practical notes. The sizing inputs interact, so pick one method and leave the others at zero to avoid confusing results - if you set custom_width/custom_height, don't also set scale_by. divisible_by is the unsung hero: a huge share of "why did my workflow error" cases are a dimension that isn't a multiple of 8, and setting this once makes it a non-issue. For upscaling, lanczos is sharpest but can ring on hard edges; bicubic is a softer alternative. And the pad/crop modes are exactly what you want when feeding a fixed-size pipeline (a video model, a fixed-canvas template) without warping people into funhouse-mirror proportions.

Where it fits: it's the general resize/reframe utility for the whole graph, not tied to background removal specifically. It pairs naturally with this pack - resize before segmentation to hit a model's sweet-spot resolution, or reframe a cutout into a target canvas after. Against ComfyUI's built-in scale nodes, the pitch is one node instead of three, with the pad/crop/divisibility logic built in.

Category🧪AILab/🖼️IMAGE

Inputs (14)

NameTypeDefaultDescription
imageIMAGE
custom_widthINT00–16384
custom_heightINT00–16384
megapixelsFLOAT0.000–16
scale_byFLOAT1.000.01–8
resize_modeCOMBOlongest_side2 options: longest_side, shortest_side
resize_valueINT00–16384
upscale_methodCOMBOlanczos5 options: nearest-exact, bilinear, area, bicubic, lanczos
deviceCOMBOcpu2 options: cpu, gpu
divisible_byINT21–512
output_modeCOMBOstretch6 options: stretch, pad, pad_edge, pad_edge_pixel, crop, pillarbox_blur
crop_positionCOMBOcenter5 options: center, top, bottom, left, right
pad_colorCOLORCODE#FFFFFFPadding color (hex)
maskoptMASK

Outputs (4)

NameTypeDescription
IMAGEIMAGE
MASKMASK
WIDTHINT
HEIGHTINT