Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Conditional Resize
ComfyUI Node

EmAySee Conditional Resize

Only resize the small ones — the upscale gate that leaves big images alone

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Conditional Resize
  • image
  • IMAGE
trigger_threshold1024
target_resolution1024
method

Most resize nodes resize, full stop. EmAySee Conditional Resize is the picky one: if your image's longest side is already at or above a threshold, it passes the image through untouched. Only if it's smaller does it upscale - and it scales to a resolution you choose. It's an upscaler with a bouncer at the door.

The use case is batch workflows with mixed inputs. Feed it ten images from different sources - some 512px thumbnails, some already 2048px - and instead of a resize node stretching everything to one size (or an upscaler wasting VRAM doubling an already-huge image), this one fixes only the undersized frames and leaves the big ones alone. It's a "normalize to a minimum quality" gate, and that's a genuinely useful thing to have in an img2img or post-processing pipeline.

How it works

The logic lives in py/EmAySee_ConditionalResize.py. It takes the image's longest side, compares it to trigger_threshold, and branches:

  • Longest side ≥ trigger_threshold → return the image unchanged.
  • Longest side < trigger_threshold → scale so the longest side becomes target_resolution, preserving aspect ratio.

The scaling is done with torch.nn.functional.interpolate in one of five modes: nearest-exact, bilinear, area, bicubic, or lanczos. Two source-level quirks worth knowing: lanczos is actually implemented as bicubic (the author's comment says so - they avoided pulling in a proper Lanczos implementation), and nearest-exact is mapped to nearest. So the "lanczos" option isn't real Lanczos.

The inputs that matter

  • image - the input frame.
  • trigger_threshold (1024) - the minimum longest-side length. Below this, resize happens.
  • target_resolution (1024) - what the longest side should become after scaling.
  • method - the interpolation mode. For upscaling, bicubic or area are the sensible picks; nearest is for pixel-art, and bilinear is a bit soft.

Output is a single IMAGE, either the original or the rescaled version.

Install

Part of the EmAySee pack:

cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes

Restart ComfyUI (or Manager → "ComfyUI_EmAySee_CustomNodes"). Category: EmAySee/Image.

Gotchas

Three things. First, the "lanczos" label is misleading - it's bicubic under the hood, so if you specifically wanted Lanczos quality you're not getting it. Second, both dimensions scale by the same factor, so aspect ratio is preserved but a very tall image gets a big height when you only meant to fix the width - the node has no "only if too small on both axes" mode. Third, the threshold comparison is on the longest side only, so a 900×1500 image at a 1024 threshold does get resized even though one dimension already exceeds 1024. Fine for most cases, but read the logic before assuming. And the pack disclaimer applies: unsupported, no guarantees - but for a resize gate, the math is simple enough to verify at a glance.

CategoryEmAySee/Image

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
trigger_thresholdINT10240–16384
target_resolutionINT10240–16384
methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos

Outputs (1)

NameTypeDescription
IMAGEIMAGE