Nodes/PlagueKind-Nodes/Unified Resize Image / Mask
ComfyUI Node

Unified Resize Image / Mask

The resize node that keeps your mask glued to your image

By PlagueKind·Created 4 months ago·Updated 2 days ago· 140
Unified Resize Image / Mask
  • image
  • mask
  • image
  • mask
  • width
  • height
scale_mode
aspect_ratio
long_side_target1024.00
short_side_target768.00
width1024.00
height1024.00
multiplier1.00
megapixels1.00
upscale_method
crop
divisible_by32.00
maintain_aspecttrue

The name undersells it. This isn't just another resize node - it's the one that finally makes image and mask follow the exact same geometry, so your inpaint region stops wandering half a pixel off between nodes. If you've ever masked something, resized the image, resized the mask separately, and watched the two quietly disagree about where the edges are, you know the exact pain this kills.

Why it exists: default ComfyUI workflows resize the image and the mask through different code paths, and when you need the mask to line up pixel-perfect - inpainting, compositing, segmentation - the drift shows up as seams and misaligned inpaint regions. This node feeds both through one geometric pipeline instead, so what's true for the image is true for the mask.

It's also the LTX-2.3 answer to a real annoyance. LTX-2.3 requires width and height both divisible by 32, and the stock resize nodes only guarantee one side cleanly. Unified Resize has a divisible_by snap (default 32) that pushes both dimensions to a clean multiple - that's the whole reason people in the announcement thread said "replaces Image Resize + Image Resize V2 + mask mismatch issues."

How it works

Pick a scale_mode and it computes target width/height, snaps to your divisible_by (set it to 1 to disable), then applies the same transform to the image and the mask. The mask path is pure tensor F.interpolate - no PIL in the loop - which is the "stable tensor-based mask resizing" claim, and it's the part that stops the mask drifting when a PIL round-trip would shift it.

The five scale modes are: Dimensions (W × H), Multiplier, Longer Side, Shorter Side, and Total Pixels (MP). The JS frontend hides the widgets you're not using, so you only ever fiddle with what applies. Wire the width/height INT outputs straight into a latent or Empty Latent Image and your latent, image, and mask all agree by construction. Handy extra: with no image connected it acts as a plain resolution selector for text-to-image/video workflows.

The inputs that matter

  • scale_mode - choose your sizing rule; the other target fields follow from it.
  • crop - center scales up past target and center-crops, which is what you want when exact dimensions matter more than full coverage.
  • divisible_by - defaults to 32 for LTX/SDXL; set 1 to disable.
  • maintain_aspect - on by default, and this is the one that'll bite you (see below).
  • upscale_method - nearest-exact, bilinear, area, bicubic, or lanczos. lanczos is sharpest but slowest; bicubic is the usual middle ground.

Install

One click via ComfyUI Manager (search "PlagueKind-Nodes"), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/PlagueKind/ComfyUI-PlagueKind-Nodes.git

Then restart ComfyUI. No extra dependencies - it's torch, comfy.utils, and a bit of math.

Where people get burned

The author got called out on this in the r/StableDiffusion announcement thread, and it's worth taking seriously: with maintain_aspect on and divisible_by set, only one side actually ends up divisible. A 1500×1000 image at longer-side 1024 snaps to 1024×682 - and 682 is not a multiple of 32. Kijai caught it in a comment, and the author's fix is to turn maintain_aspect off when you need both dimensions clean. For LTX-2.3, that's most of the time, so flip it and stop fighting.

Also don't repeat the README's "no PIL dependency issues" back at anyone too loudly - the mask path is tensor-only, but lanczos on the image side still routes through comfy.utils, which uses PIL. Fine in practice; just know which claim applies where.

CategoryPlagueKind/image

Inputs (14)

NameTypeDefaultDescription
scale_modeCOMBO5 options: Dimensions (W × H), Multiplier, Longer Side, Shorter Side, Total Pixels (MP)
aspect_ratioCOMBO9 options: Auto (Input Image), 1:1 (Square), 2:3 (Portrait Photo), 3:2 (Photo), 3:4 (Portrait Standard), 4:3 (Standard), +3
long_side_targetFLOAT1024.001–16384
short_side_targetFLOAT768.001–16384
widthFLOAT1024.001–16384
heightFLOAT1024.001–16384
multiplierFLOAT1.000.01–100
megapixelsFLOAT1.000.01–100
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
cropCOMBO2 options: disabled, center
divisible_byFLOAT32.001–512
maintain_aspectBOOLEANtrue
imageoptIMAGE
maskoptMASK

Outputs (4)

NameTypeDescription
imageIMAGE
maskMASK
widthINT
heightINT