Nodes/DemonAlone-nodes-ComfyUI/Image and Mask Resize
ComfyUI Node

Image and Mask Resize

Stretch, crop, or pad — and it won't crash on a missing image

By DemonAlone·Created 7 months ago·Updated 22 days ago· 3
Image and Mask Resize
  • image
  • mask
  • image_out
  • mask_out
  • width
  • height
width512
height512
method
interpolation
condition
multiple_of1

Worth saying up front: this node is the author's own port of the "🔧 Image Resize" node from ComfyUI_essentials, one of the more widely installed general-utility packs in the ecosystem. If you already have essentials installed, you already have this exact functionality, tested by a much bigger user base. What you're getting here is a lightweight, self-contained equivalent if you'd rather not pull in a whole extra pack for one resize node.

What it does

Every single field on this node is optional - including the image and mask themselves. That's deliberate: per the author's own description, it "automatically handles empty outputs if an input tensor is missing," so you can leave this node sitting in a graph without an image wired to it yet and it won't throw.

The real controls: width and height (default 512, up to a generous 16834) set your target size, and method decides how the source gets there - stretch distorts to hit the exact dimensions, keep proportion scales while preserving aspect ratio, fill / crop scales to fill the target and crops the overflow, and pad scales to fit inside the target and pads the remainder. interpolation picks the resampling filter (nearest, bilinear, bicubic, area, nearest-exact, lanczos - lanczos is the sharp, general-purpose choice for most upscales). condition gates whether the resize happens at all: always, or only downscale if bigger / upscale if smaller / by area - useful in a batch pipeline where you don't want to upscale images that are already big enough. multiple_of rounds the final dimensions to a multiple of that number, which matters because most diffusion models want dimensions divisible by 8 (or more, for some architectures) - set it to match your model's requirement and this node handles the rounding for you.

Outputs mirror the inputs: image_out, mask_out, plus the resulting width and height as plain integers - handy if a downstream node needs to know the actual final size rather than assuming it matches what you typed.

Installing it

ComfyUI Manager: search DemonAlone-nodes-ComfyUI, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/DemonAlone/SimpeStringGenerator_ComfyUI

No extra dependencies beyond core ComfyUI and Pillow/torch, which you already have.

Where people get burned

Since width/height technically go down to 0, don't leave them there by accident - a 0-pixel target isn't a useful resize, it's a bug waiting to surface downstream. And remember condition only controls whether it resizes, not how - if you set it to downscale if bigger and your source is already smaller than the target, the image passes through unchanged, which is correct behavior but easy to mistake for the node silently doing nothing.

If you're using this as a pre-scale step ahead of a tiled diffusion upscaler, keep in mind pixel resizing and generative upscaling are different jobs - this node adds no detail, it just changes pixel count. For actually inventing detail on a soft or low-res source, you want a generative pass on top of this, not instead of it.

Categoryutils

Inputs (8)

NameTypeDefaultDescription
imageoptIMAGE
maskoptMASK
widthoptINT5120–16834
heightoptINT5120–16834
methodoptCOMBO4 options: stretch, keep proportion, fill / crop, pad
interpolationoptCOMBO6 options: nearest, bilinear, bicubic, area, nearest-exact, lanczos
conditionoptCOMBO5 options: always, downscale if bigger, upscale if smaller, if bigger area, if smaller area
multiple_ofoptINT11–512

Outputs (4)

NameTypeDescription
image_outIMAGE
mask_outMASK
widthINT
heightINT