OpenCV resize_0
Exact, fast resizing with real OpenCV interpolation — resize_0
- src
- dst
- nparray
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- anNPARRAY, fromImage2Nparray.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. Whendsizeis(0, 0), OpenCV falls back to the scale factors instead.fx,fy- float scale factors. Multipliers, not percentages:0.5halves the image. Ignored whendsizeis nonzero.interpolation-0nearest,1linear,2cubic,3=INTER_AREA(best for downscaling),4Lanczos. For downscales, reach for3; for upscales,2or4.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/fyirrelevant. - 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| fx | FLOAT | — | |
| fy | FLOAT | — | |
| interpolation | INT | — | |
| dsizeopt | STRING | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |