Nodes/ComfyUI-DD-Nodes/DD Image Size Limiter
ComfyUI Node

DD Image Size Limiter

The safety valve that keeps your VRAM from becoming a statistic

By Dontdrunk·Created 2 years ago·Updated 24 days ago· 182
DD Image Size Limiter
  • 图像1
  • 遮罩1
  • 图像2
  • 遮罩2
  • 图像3
  • 遮罩3
  • 图像4
  • 遮罩4
  • 图像
  • 遮罩
  • 原始宽度
  • 原始高度
  • 新宽度
  • 新高度
最大长宽2048
最小长宽256
缩放方法双线性插值
选择输出1

Somewhere in your workflow there's an upscaler, a video loader, or a pile of user-dropped images that will happily hand the VAE a 6000×4000 monster and let the OOM error speak for itself. DD Image Size Limiter is the gatekeeper you put in front of that: give it a max side and a min side, and any image outside that range gets resized back inside it while keeping its aspect ratio. It's the "have you tried not blowing up your GPU" node.

How it works

You connect up to four image-plus-mask pairs - 图像1 (Image 1) with 遮罩1 (Mask 1), and so on - plus two limits: 最大长宽 (Max Side, default 2048) and 最小长宽 (Min Side, default 256). Any image whose longest edge exceeds the max gets scaled down to fit; anything smaller than the min gets scaled up. Crucially it preserves aspect ratio, so nothing gets squashed, and the mask rides along with its matching image so they stay in lockstep. 选择输出 (Select Output) chooses which of the four pairs comes out, and 缩放方法 (Scaling Method) picks the interpolation - bilinear default, lanczos if you want to squeeze quality out of the upscale direction, nearest for masks.

The outputs are unusually informative for a utility node: the resized 图像 (Image), the resized 遮罩 (Mask), and both the original and new width and height as INTs. That last bit is gold if you ever need to know what actually changed - you can log it, compare it, or use it to confirm your limiter is doing work.

When you'd reach for it

Two situations, really. First, batch processing where you can't trust the input: users (or your own future self) drop wildly different-sized images into a folder, and you want every output capped at 2048 so the VAE decode doesn't become the night's OOM event. Second, as a defensive stage before expensive operations - put it ahead of VAE decode, upscale passes, or inpainting where oversized input multiplies memory cost. It won't fix a genuinely bad image, but it caps the damage.

Installation

Part of the DD-Nodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Dontdrunk/ComfyUI-DD-Nodes
cd ComfyUI-DD-Nodes && pip install -r requirements.txt

Restart ComfyUI, or ComfyUI Manager → "ComfyUI-DD-Nodes". Nothing extra to download.

Where people get burned

The min-side behavior surprises people: it upscales small images, which can waste VRAM if you set the floor too high on a workflow fed by thumbnails. And the limiter only kicks in when an image is outside the range - inside the range it passes through untouched, which is the correct behavior but means a 3000px image with max set to 2048 will get shrunk, so pick limits deliberately. It's a dumb, reliable guardrail, and in the era of 4K upscale pipelines that's exactly what you want in the path. Labels are Chinese by default; the pack ships an English locale.

Category🍺DD系列节点

Inputs (12)

NameTypeDefaultDescription
图像1IMAGE
最大长宽INT204864–8192
最小长宽INT2568–4096
缩放方法COMBO双线性插值5 options: 双线性插值, 邻近-精确, 区域, 双三次插值, lanczos
选择输出INT11–4
遮罩1optMASK
图像2optIMAGE
遮罩2optMASK
图像3optIMAGE
遮罩3optMASK
图像4optIMAGE
遮罩4optMASK

Outputs (6)

NameTypeDescription
图像IMAGE
遮罩MASK
原始宽度INT
原始高度INT
新宽度INT
新高度INT