OpenCV rotate_0
90-degree flips, instant and lossless
- src
- dst
- nparray
rotate_0 wraps cv2.rotate, and despite the generic name it does one specific thing: rotates an image by 90, 180, or 270 degrees. Not arbitrary angles. If you need 23.7 degrees, this is the wrong node - that's warpAffine + getRotationMatrix2D territory, which is a whole other beast. But for the common "my generated image is sideways and I need it portrait" or "flip this for the next pass" jobs, this is the cleanest tool in the pack.
How it works
The mechanism is dead simple, which is the point. A 90-degree rotation is just a reordering of pixels - no interpolation, no resampling, no blurring that comes along for the ride. Where a free-angle rotation has to invent pixels at the corners and smears everything slightly, this is lossless: the output is exactly the input's pixels, rearranged. That makes it useful mid-pipeline where you don't want a resample silently degrading your image (the same reason post-processing folks reach for integer scaling, not smooth filters - the KB's post-processing doc makes that case).
Inputs and outputs
Inputs: src (NPARRAY) and rotateCode (INT). The code is an integer, and this is where people stumble because OpenCV's constants are plain numbers - there's no dropdown. 0 = rotate 90° clockwise (ROTATE_90_CLOCKWISE), 1 = 180°, 2 = 90° counterclockwise (ROTATE_90_COUNTERCLOCKWISE). Everything else is an error. The dst input is an optional out-parameter - the README's standing advice is to avoid those, so leave it alone. Output is a single nparray you can feed into Nparrays2Image to get back a Comfy IMAGE.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Setup is the same as every node in this pack: install opencv-comfyui via ComfyUI Manager (search "opencv-comfyui") or the commands above, then ensure OpenCV is installed (the pack's requirements.txt declares opencv-contrib-python; no model downloads, no weights). Remember the conversion dance: Comfy images are RGB IMAGE tensors, OpenCV works on BGR numpy arrays, so you'll run Image2Nparray in and Nparrays2Image out, with cvtColor where the channel order matters.
Common issues
Common issues: feeding it a batch bigger than one - Image2Nparray only accepts batch_size==1, so use ImageFromBatch (length=1) to pull a single frame first. And forgetting that rotateCode wants a number: type 0, 1, or 2 in the widget, not "90" - the constant names don't appear anywhere in the UI, so bookmark the mapping. The _0/_1 variants are the MatLike/UMat overloads and behave identically.
Verdict
Honestly, if all you want is to reorient a picture, this is fine but nothing special - you could equally use ComfyUI's built-in flip or transform nodes. Where it earns its place is inside a bigger OpenCV pipeline where everything is already an NPARRAY, and you want a rotation that costs nothing and changes no pixels.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| rotateCode | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |