Nodes/ComfyUI_yanc/๐Ÿ˜ผ> Rotate Image
ComfyUI Node

๐Ÿ˜ผ> Rotate Image

A rotate node that actually gives you a mask for the empty corners

By ALatentPlaceยทCreated 2 years agoยทUpdated 2 years agoยท 80
๐Ÿ˜ผ> Rotate Image
  • image
  • image
  • mask
โ—„rotation_angle0โ–บ

Rotating a rectangular image by anything other than a multiple of 90 degrees leaves gaps - the corners of the new, rotated canvas that used to be outside the original frame are now empty. Most simple rotate nodes just fill that with black or transparent and leave you to deal with it. This one hands you a mask marking exactly where those gaps are, which is what actually makes rotation useful for compositing.

The use case the author calls out directly: rotate a layer, then use vanilla ComfyUI's ImageCompositeMasked node to drop it onto a background using the mask this node produces, so the empty corners show the background through instead of black triangles. Think tilted photo-in-frame effects, angled stickers/overlays composited onto a scene, or straightening/de-straightening a scanned image before further processing.

How it works

You give it an image and an angle; it rotates the image by that many degrees and expands the mask to cover the area that rotation exposes (the parts of the new canvas that have no source pixels). The image and mask come out at the same dimensions, ready to plug into a compositing node together.

The inputs and outputs that matter

  • image - the IMAGE to rotate.
  • rotation_angle (INT, default 0, range โˆ’359 to 359) - degrees of rotation. Positive and negative both work, so you don't need to do the "360 minus your angle" math to rotate the other direction.

Two outputs: image (the rotated result) and mask (the MASK marking the newly-empty corner regions). Feed both into ImageCompositeMasked along with a background image to composite the rotated layer cleanly.

How to install it

Via ComfyUI Manager: search "yanc" or "YANC - Yet Another Node Collection," install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ALatentPlace/ComfyUI_yanc

then restart. No extra dependencies, no model downloads - this is a straightforward image-tensor rotation, nothing heavier under the hood.

Common issues & troubleshooting

Rotated corners are black instead of transparent-looking in your final output. That's expected if you only use the image output on its own - the node still fills the exposed corners with something (typically black) because an IMAGE tensor can't be "empty." The mask output is what tells a downstream compositing node which pixels to actually treat as background rather than content. Skip the mask and you'll bake the fill color in.

The composite still shows edges/artifacts around the rotated area. Straight-edge masks from a geometric rotation can look harsh where they meet the background, especially at odd angles. A small Gaussian blur on the mask before it hits ImageCompositeMasked (a vanilla ComfyUI mask-blur node handles this) softens the seam.

Canvas size stays the same as the input, and content gets clipped at extreme angles. This node rotates within the existing image dimensions rather than expanding the canvas to fit the full rotated bounding box - at 45 degrees on a non-square image, corners of your original content can get cropped off. If you need the whole rotated image preserved with no clipping, pad the canvas (upscale onto a larger transparent canvas) before rotating.

CategoryYANC/๐Ÿ˜ผ Image

Inputs (2)

NameTypeDefaultDescription
imageIMAGEโ€”
rotation_angleINT0-359โ€“359โ€”

Outputs (2)

NameTypeDescription
imageIMAGEโ€”
maskMASKโ€”