Rotate Image
ComfyUI custom nodes for angle-based image rotation with high-quality interpolation and lossless restoration
ComfyUI Rotate Image
A pair of ComfyUI custom nodes for angle-based image rotation in processing pipelines. Rotate an image by any angle, run it through other nodes (inpainting, img2img, upscaling, …), then perfectly restore it to its original dimensions.
Nodes
🔄 Rotate Image
Rotates an IMAGE (and optional MASK) by a specified angle. The canvas is automatically expanded so no content is clipped, and new areas are filled with black. A ROTATION_INFO value is emitted so the paired Restore Rotated Image node can exactly reverse the transformation.
Inputs
| Name | Type | Description |
|------|------|-------------|
| image | IMAGE | Input image |
| angle | FLOAT | Rotation angle in degrees (−360 to 360). Positive = counter-clockwise |
| interpolation | COMBO | Resampling algorithm — see table below |
| mask (optional) | MASK | Input mask — rotated with the same transformation |
Outputs
| Name | Type | Description |
|------|------|-------------|
| image | IMAGE | Rotated image with expanded black-filled canvas |
| mask | MASK | Rotated mask (or a black mask if none was provided) |
| rotation_info | ROTATION_INFO | Metadata required by Restore Rotated Image |
↩️ Restore Rotated Image
Reverses the rotation applied by Rotate Image and crops the result back to the original image dimensions. Wire the rotation_info output of Rotate Image directly into this node.
Inputs
| Name | Type | Description |
|------|------|-------------|
| image | IMAGE | Processed rotated image |
| rotation_info | ROTATION_INFO | Metadata from Rotate Image |
| mask (optional) | MASK | Processed mask to restore |
Outputs
| Name | Type | Description |
|------|------|-------------|
| image | IMAGE | Restored image, cropped to original dimensions |
| mask | MASK | Restored mask, cropped to original dimensions |
Interpolation Algorithms
Choose the resampling method that best suits your use case:
| Method | Quality | Speed | Best For |
|--------|---------|-------|----------|
| NEAREST | ★☆☆☆ | ⚡⚡⚡⚡ | Pixel art, binary masks |
| BILINEAR | ★★☆☆ | ⚡⚡⚡ | Quick previews |
| BICUBIC | ★★★☆ | ⚡⚡ | Photos — default |
| LANCZOS | ★★★★ | ⚡ | Maximum quality (uses BICUBIC for the affine rotation step — PIL limitation) |
Tip: Use
LANCZOSorBICUBICto avoid mosaic/pixelation artifacts on photographic content.
Typical Workflow
[Image] ──► Rotate Image ──► [KSampler / Inpaint / Upscale / …] ──► Restore Rotated Image ──► [Result]
│ ▲
└──────────────── rotation_info ────────────────────────────►─┘
- Connect your source image to Rotate Image.
- Set the desired
angleandinterpolation. - Wire the
image(and optionallymask) outputs into your processing nodes. - Wire the
rotation_infooutput directly to Restore Rotated Image. - Connect the processed image (and mask) from your pipeline into Restore Rotated Image.
- The restored output will have exactly the same dimensions as the original input.
Installation
Via ComfyUI Manager (recommended)
Search for "Rotate Image" in the ComfyUI Manager and click Install.
Manual
cd ComfyUI/custom_nodes
git clone https://github.com/YOUR_USERNAME/comfyui-rotate-image
Restart ComfyUI. No additional dependencies are required — the nodes use only libraries already bundled with ComfyUI (torch, Pillow, numpy).
Notes
- Batch support: Both nodes correctly handle batched images (multiple images in a single tensor).
- Angle convention: Positive angles rotate counter-clockwise (PIL convention). Use negative angles for clockwise rotation.
- 0° / 360°: The image is returned unchanged.
- Size-altering pipelines: If your processing nodes change the image size (e.g. upscaling), Restore Rotated Image still performs the correct inverse rotation and crops to the original dimensions stored in
rotation_info. - ROTATION_INFO type: This is a custom ComfyUI type — it can only be connected between a Rotate Image output and a Restore Rotated Image input.