Nodes/opencv-comfyui/OpenCV resize_0
ComfyUI Node

OpenCV resize_0

Exact, fast resizing with real OpenCV interpolation — resize_0

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV resize_0
  • src
  • dst
  • nparray
fx
fy
interpolation
dsize

resize_0 is the one node in this pack you'll actually use on a normal Tuesday: it resizes an image to an exact pixel size or a scale factor, with OpenCV's full menu of interpolation algorithms. It's wrapped for ComfyUI by opencv-comfyui (geroldmeisinger/opencv-comfyui).

Yes, ComfyUI already ships ImageScale, and for most workflow plumbing that's fine. The case for this one is precision and control. INTER_AREA for downscaling - the algorithm that genuinely looks better when you shrink a high-res render - isn't in ComfyUI's default scale node, and neither is the ability to resize in NPARRAY land with zero floating-point surprises. If you're preprocessing for a ControlNet, building a dataset, or just want a downscale that doesn't shimmer, this is the sharper tool.

The inputs that matter

  • src - an NPARRAY, from Image2Nparray.
  • dsize - the target size as a literal: (width, height) - and note the order, it's columns-then-rows, the opposite of numpy's (H, W) habit. When dsize is (0, 0), OpenCV falls back to the scale factors instead.
  • fx, fy - float scale factors. Multipliers, not percentages: 0.5 halves the image. Ignored when dsize is nonzero.
  • interpolation - 0 nearest, 1 linear, 2 cubic, 3 = INTER_AREA (best for downscaling), 4 Lanczos. For downscales, reach for 3; for upscales, 2 or 4.
  • dst - optional out-parameter; leave it unconnected.

Output is the resized nparray, back out through Nparrays2Image.

The gotcha that will bite you first

dsize is a literal string, and the pack parses it with literal_eval - so it must not be left empty. If you want to resize by scale factor, put (0, 0) in dsize and set fx/fy; leaving the field blank throws the pack's signature invalid syntax (<unknown>, line 0) error. That single rule trips up more people than anything else on this node. The two sane modes:

  • Exact size: dsize = (512, 512), fx/fy irrelevant.
  • Scale factor: dsize = (0, 0), fx = 0.5, fy = 0.5.

Installing it

ComfyUI Manager (search "opencv-comfyui"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

restart, and confirm OpenCV is installed:

pip install opencv-contrib-python

No models, no GPU - this is a fast CPU op. And remember the shape ordering: (width, height), not (height, width). Mix those up once on a 1024×1024 image and you'll never forget it.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
srcNPARRAY
fxFLOAT
fyFLOAT
interpolationINT
dsizeoptSTRING
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY