Image Rotate
Rotate by any angle, counter-clockwise — and expand the canvas or don't
- image
- image
CdlImageRotate spins an image by any angle in degrees - not just the 90° increments - using bilinear interpolation, and the one decision you have to make is whether the canvas grows to fit the rotated content. Set angle to 45 and expand to true and you get the whole diamond, corners and all. Leave expand off and the output keeps the input size, which means rotated corners get cut off and the gaps fill with black.
The angle is counter-clockwise, and the direction trips people up more than anything else in this node. In your head, rotate is rotate - but 90° here means counter-clockwise, and if you're used to image editors where positive angles spin clockwise, your first result will be mirrored from what you expected. Flip the sign and move on.
It lives in ComfyDL's self-developed Image Tools category (the author's own nodes, separate from the d2l textbook ports). Its natural companions in the pack are Image Flip and Image Resize - you can rotate, mirror, and size a batch of frames in one chain before feeding them into a model or a dataset node.
How it works
The node permutes your [B, H, W, C] image to channel-first and calls torchvision's rotate with bilinear interpolation and fill=0 - so any area the rotated image doesn't cover becomes black, not transparent. expand controls the output canvas: true grows it to contain the full rotated image, false keeps the original dimensions and clips whatever pokes out. The output is converted back to the standard IMAGE layout and clamped to [0, 1].
Inputs and output
Only three things to touch:
image- anyIMAGE; every frame in the batch gets the same rotation.angle- float, −360 to 360, default 90, counter-clockwise. Negative values rotate clockwise.expand- boolean, defaultfalse. Turn it on when you actually want the full rotated content; leave it off when you need the output to stay the same dimensions (for example, feeding a model that expects a fixed input shape).
The single output is image, same batch size, dimensions depending on expand.
Installing ComfyDL
It ships with the ComfyDL pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ComfyDL/requirements.txt
Restart ComfyUI. The only extra dependency is matplotlib; torch and torchvision come with ComfyUI. ComfyUI Manager users: search "ComfyDL" - if it's not in the built-in list (the pack isn't published to the official Comfy Registry yet), use Install via Git URL with https://github.com/Cynthia-lxx/ComfyDL.
Common issues
The black corners are the top complaint. expand=false is the default, so casual users rotate a photo 30° and get black triangles in the corners, then assume the node is broken. It isn't - flip expand on if you want the full frame. And because expand changes the output size, remember that a fixed-shape model downstream will reject the result if the dimensions drift; in that case keep expand off and accept the clipping, or resize after. Also note the counter-clockwise convention - one sign error and everything's mirrored, and the fix is just a negative angle.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| angle | FLOAT | 90-360–360 | — |
| expand | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |