ComfyUI Node

Ihor Resize

Resize an image and its mask together, and get the dimensions back — Ihor Resize does the math you keep doing by hand

By ihorpankin·Created 6 months ago·Updated 6 months ago· 0
Ihor Resize
  • image
  • mask
  • upscale_model
  • image
  • mask
  • height
  • width
upscale_method
resize_mode
target_side1024
width1024
height1024
show_previewtrue

ComfyUI's core resize nodes are dumb in a specific way: you tell ImageScale a width and a height and it just stretches. There's no built-in "make the longest edge 1024, keep the ratio" - which is exactly the operation you want when you're prepping an input photo before SDXL or Flux, where the model likes its native resolution and the input can be any shape. Ihor Resize exists to be that node, and it quietly fixes a second thing core doesn't: it keeps the image and its mask in lockstep, and it hands you the resulting dimensions as numbers you can wire into something else.

The author calls it a resize node, but it's really three tools in one trench coat: an aspect-ratio-preserving resizer, an image+mask sync node, and a mini AI-upscale-in-the-middle. For a single small utility that's a surprising amount of reach.

How it works

You feed it an image, pick a mode, and it computes the target size:

  • resize - stretch to the explicit width × height you set.
  • longest side - scales so the longer edge equals target_side, the other edge follows the ratio. Portrait photos become 768×1024, not 1024×1024.
  • smallest side - same idea but keyed to the shorter edge. Great for "make sure nothing crops below a certain size."

The interpolation method is your choice from the usual suspects (nearest-exact, bilinear, area, bicubic, lanczos) - plain ComfyUI interpolation, no model involved. Two inputs make it more interesting. Plug an upscale_model (the same UPSCALE_MODEL type that UpscaleModelLoader produces - 4x-UltraSharp and friends) and, only when the target is larger than the source, it runs the model first with ComfyUI's tiled upscale, then interpolates down to your exact target. So you can say "upscale this to longest-side 1024" and it lands on 1024 precisely, not 1024-and-a-bit. If the target isn't bigger, the model is simply ignored - that's by design, but it's the easiest thing to misread when nothing seems to happen.

If you connect a mask, it's resized (bilinear) to match the output, so you never end up with a mask that no longer lines up with the image - the classic failure when you resize each with separate nodes that round differently. And unlike most resize nodes it's an output node with a show_preview toggle: leave it on and it saves a preview to ComfyUI's temp folder, so it can be the end of your branch without a separate PreviewImage node. The downside of that is each frame in a batch gets its own PNG written to temp, so if you run video frames through it, turn show_preview off or your temp dir fills up.

The outputs that matter

You get image and mask, obviously, but the sleeper hit is height and width as INTs. Wire those into an EmptyLatentImage (or into a conditioning's resolution) and your latent matches the resized image exactly - no guessing, no "I think it was 896 wide." That's the pattern this node is actually worth having for: resize → get dims → latent agrees → no misalignment later.

Install

No dependencies beyond ComfyUI itself, no model downloads, nothing to configure. Either:

  • ComfyUI Manager - search "comfyui-ihor-resize" and install, or
  • cd ComfyUI/custom_nodes && git clone https://github.com/ihorpankin/comfyui-ihor-resize

Restart, and it appears under image/transform as Ihor Resize. That's it - the whole pack is this one node in one file, and the code only uses ComfyUI's built-in comfy.utils, so there's no requirements.txt to fight with.

Gotchas worth knowing

  • Feed no mask and the mask output is a zeroed mask of the output size - all black, "nothing selected." Don't wire that into an inpaint step expecting your original selection.
  • The 4x upscaler runs at its native factor first: a 512×512 through 4x-UltraSharp becomes 2048, then gets interpolated back down to your 1024 target. Slightly wasteful; for a quick longest-side prep, skip the model and just use bicubic/lanczos.
  • It's an obscure, fresh pack with zero community footprint, so treat it as "small, clean, unproven in the wild" rather than battle-tested. For a resize-and-report-dims job it's solid; for anything fancy, keep your usual upscaling stack.

A genuinely handy little node if you resize images (or inpaint, where mask alignment matters) more than once a week. The dimension outputs alone justify the install.

Categoryimage/transform

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
resize_modeCOMBO3 options: resize, longest side, smallest side
target_sideINT10241–16384
widthINT10241–16384
heightINT10241–16384
show_previewBOOLEANtrue
maskoptMASK
upscale_modeloptUPSCALE_MODEL

Outputs (4)

NameTypeDescription
imageIMAGE
maskMASK
heightINT
widthINT