Rotate Image (Any Angle)
Rotate RGB or RGBA images and masks at arbitrary angles with configurable scaling and backgrounds in ComfyUI.
Rotate Image (Any Angle) Node
日本語 | English
A custom ComfyUI node that rotates RGB or RGBA images at any angle while preserving the original canvas size, tensor dtype, and device. It can also rotate a ComfyUI mask and preserve or fill transparent areas.
<img width="1572" height="1920" alt="Rotate Image (Any Angle)node exampl" src="https://github.com/user-attachments/assets/42d32328-a410-4b88-8a0c-9131ef46d3db" />Installation
-
Clone this repository into
ComfyUI/custom_nodes:cd ComfyUI/custom_nodes git clone https://github.com/palealloy2999-prog/comfyUI-rotate-image.git -
Restart ComfyUI.
-
Search for
Rotate Image (Any Angle)in the node list.
Workflows created before the Registry-ready release used the internal node ID RotateImageNode. Replace that node after upgrading; the current internal ID is ImageRotateAnyAngle_PaleAlloy.
Inputs
- image: RGB or RGBA image tensor
- mask: optional ComfyUI mask where 1 is transparent and 0 is opaque
- angle: rotation angle in degrees
- size_mode:
- cover: enlarge the image until the rotated result covers the entire canvas, cropping overflow
- original: rotate at the original 1:1 scale (default)
- contain: shrink the image until the complete rotated result fits inside the canvas
- match_short_edge: match the short edge of the rotated bounding box to the canvas short edge
- match_long_edge: match the long edge of the rotated bounding box to the canvas long edge
- background_mode:
- transparent: preserve source transparency and make the rotated canvas outside the image transparent
- white: fill source transparency and the rotated canvas background with white (default)
- black: fill source transparency and the rotated canvas background with black
- custom: fill source transparency and the rotated canvas background with a custom hex color
- custom_color: custom background color in hex format (for example #FF00AA)
Size and background modes are independent, so combinations such as contain with black or original with transparent are supported. Unlike contain, the edge-matching modes can crop the opposite edge when the rotated aspect ratio differs from the canvas. Connect the MASK output from ComfyUI's Load Image node to preserve or fill PNG transparency correctly. RGBA alpha and a connected mask are combined. The white, black, and custom modes produce a fully opaque output mask.
To preview or save transparent output as RGBA, connect this node's image and mask outputs to ComfyUI's Join Image with Alpha node.
Output
- image: rotated image tensor with the same batch size, height, width, channel count, dtype, and device as the input
- mask: rotated ComfyUI mask; it is empty for the opaque fill modes