ComfyUI Node

XImageResize

One resize node that won't fight your batch or your divisibility

By Xz3r0-M·Created 8 months ago·Updated about 6 hours ago· 13
XImageResize
  • image_or_mask
  • resize_settings_in
  • Processed_Data
  • width
  • height
  • resize_settings_out
use_passed_settingstrue
output_resize_settingstrue
scale_modeBilinear
edge_modeLong
resize_conditionAlways
target_edge1280
megapixels1.0
scale_multiplier1.0
divisible_modeDisabled
divisible16
width_offset0
height_offset0
skip_on_emptyfalse

Resizing sounds like the least interesting thing you can do to an image, and then you hit a batch where every frame has a different size and your VAE or model quietly refuses. XImageResize is this pack's attempt to make resize boring in the good way: it handles images or masks, scales by long edge, short edge, megapixels, or a multiplier, snaps to a divisibility requirement (so the result plays nice with 8/16/32/64-based models), and - the part that stands out - can propagate its settings to downstream resize nodes so a whole chain resizes to the same target instead of drifting.

How it works

You feed it image_or_mask (a MatchType port) and it returns the resized data plus the resulting width and height. The scale_mode dropdown picks your interpolation: Nearest-exact (fastest), Bilinear (fast, medium quality), Area (best for downsampling), Bicubic (high quality), or Lanczos (highest quality, slowest). The tooltip carries the one tip that matters for masks: use Nearest-exact for MASK input to avoid edge drift on the mask boundary - a real, practical detail that most resize nodes don't bother telling you.

The scaling behavior is chosen by edge_mode:

  • Long - fit the long edge to target_edge (default 1280).
  • Short - fit the short edge.
  • Megapixels - hit a target pixel count (0.1–100 MP).
  • Scale Multiplier - plain 1.0–10.0 multiply.

resize_condition gates Long/Short/Megapixels modes: Always, Only if Larger, or Only if Smaller. Note the subtlety in the tooltip - if the condition isn't met, resizing is skipped, but divisible and offset are still applied, so you don't silently get an off-model resolution.

The batch-unified bit

The genuinely clever feature is the settings chain. A node has resize_settings_in (optional, from an upstream XImageResize) and resize_settings_out, carrying an XZ3R0_RESIZE_SETTINGS type. With use_passed_settings on, a downstream node inherits the chain-origin settings for its calculation; with output_resize_settings on, the settings keep forwarding. The point: set your target once at the head of a chain and every downstream resize obeys the same target - which is exactly what you want when every image in a batch has to land on the same canvas. This is the "resize coordinator" pattern, and it's the reason to reach for this node over the built-in ImageScale.

Inputs that matter

  • scale_mode / edge_mode / resize_condition / target_edge - the main scaling controls.
  • divisible (default 16) with divisible_mode (Nearest/Up/Down) - snap resolution to a multiple; set to 1 to disable.
  • width_offset / height_offset (-128 to +128) - nudge the result, e.g. to make room for an inpaint pad.
  • use_passed_settings / output_resize_settings - the chain logic above.

Outputs: Processed_Data (resized image or mask), width, height, resize_settings_out.

Installing it

Part of ComfyUI-Xz3r0-Nodes. ComfyUI Manager: search ComfyUI-Xz3r0-Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Xz3r0-M/ComfyUI-Xz3r0-Nodes.git
cd ComfyUI-Xz3r0-Nodes
pip install -r requirements.txt

Restart ComfyUI. No FFmpeg needed for this node.

Gotchas

The most common miss is forgetting that divisible adjustment still happens even when resize_condition skips the resize - if your image comes out a hair different than you computed by hand, that's usually the divisibility snap. And mind the mask rule: a mask resized with a smooth filter picks up soft edges that change what the mask means. One honest note from the KB: resizing is not upscaling - a resize node adds no detail, it just interpolates. For "make it bigger and better," you pair this with a real upscaler, not a resize.

Category♾️ Xz3r0/Workflow-Processing

Inputs (15)

NameTypeDefaultDescription
image_or_maskCOMFY_MATCHTYPE_V3Input image or mask
use_passed_settingsBOOLEANtrueWhen enabled and settings input is connected, use passed settings for this node's resize calculation. When disabled, this node uses local panel values only.
output_resize_settingsBOOLEANtrueWhen disabled, resize_settings_out outputs empty value, equivalent to leaving this port unconnected.
scale_modeCOMBOBilinearSelect interpolation algorithm: Nearest-exact=fastest, Bilinear=fast & medium quality, Area=best for downsampling, Bicubic=medium speed & high quality, Lanczos=slow & highest quality. For MASK input, Nearest-exact is recommended to avoid edge drift.
edge_modeCOMBOLongSelect scaling mode: Long=long edge, Short=short edge, Megapixels=target pixels, Scale Multiplier=scale by multiplier
resize_conditionCOMBOAlwaysResize condition for Long/Short/Megapixels: Always=always resize, Only if Larger=resize only when image is larger than target, Only if Smaller=resize only when image is smaller than target. Ignored in Scale Multiplier mode. If the condition is not met, resizing is skipped, but divisible and offset are still applied.
target_edgeINT128064–8192Target edge length in pixels (ignored in Megapixels and Scale Multiplier modes)
megapixelsFLOAT1.00.1–100Only used in Megapixels mode as target value (must be >0)
scale_multiplierFLOAT1.00.1–10Scale multiplier (only used in Scale Multiplier mode)
divisible_modeCOMBODisabledHow to adjust resolution to be divisible: Disabled=no adjustment, Nearest=round to nearest multiple, Up=round up, Down=round down
divisibleINT161–128Make resolution divisible by this number (set to 1 to disable, common values: 8, 16, 32, 64)
width_offsetINT0-128–128Add offset to output width (positive=increase, negative=decrease, default=0)
height_offsetINT0-128–128Add offset to output height (positive=increase, negative=decrease, default=0)
skip_on_emptyBOOLEANfalseWhen enabled, outputs None for all ports if no input image is connected, instead of raising an error.
resize_settings_inoptXZ3R0_RESIZE_SETTINGSOptional resize settings from previous XImageResize node

Outputs (4)

NameTypeDescription
Processed_DataCOMFY_MATCHTYPE_V3Resized image or mask output tensor
widthINTOutput resolution width
heightINTOutput resolution height
resize_settings_outXZ3R0_RESIZE_SETTINGSSettings passed to downstream nodes. If valid upstream settings exist, this output keeps forwarding the chain-origin settings.