Nodes/Dream Painter/πŸ”Ž Bitmap Rotate
ComfyUI Node

πŸ”Ž Bitmap Rotate

Rotate a bitmap β€” and don't forget the center defaults to 256,256

By alt-key-projectΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 2
πŸ”Ž Bitmap Rotate
  • BITMAP
  • BITMAP
β—„degrees45β–Ί
β—„center_x256β–Ί
β—„center_y256β–Ί
β—„expandβ€”β–Ί
β—„fill_colorβ–Ύβ–Ί

Rotating a bitmap sounds trivial until you try it. You spin a shape 45 degrees, the result is lopsided, and you realize rotation is only well-defined if you know around what point - and that point is the one thing the defaults get wrong. Bitmap Rotate is the pack's rotation node, and once you understand its center input, it does the job fine.

In DPaint's world there are two different rotation nodes and people mix them up. Shape Rotate spins a shape around its own center in vector space, before rendering. Bitmap Rotate rotates the pixels of an already-rendered bitmap, and it asks you to specify the center - which is the whole game. If you're rotating rendered geometry, this is the one you want; if you're still working in shapes, do it upstream instead and save yourself the pixel resampling.

How it works

Pillow's rotate() on the one-bit image, with bilinear resampling. Three things to set:

  • degrees - rotation angle, βˆ’360 to 360. Positive is counterclockwise (PIL convention).
  • center_x / center_y - the pivot point in pixels. These default to 256,256, which only makes sense for a 512Γ—512 bitmap. If your bitmap is anything else, the pivot is wrong and the rotation looks like an orbit. Set these to half your bitmap's width/height (that's a job for Bitmap Dimensions).
  • expand - when on, the canvas grows to fit the rotated content instead of clipping the corners. Leave it off and corners get cut off.
  • fill_color - black or white, the color that fills the newly exposed areas when the shape no longer covers them.

Inputs and outputs

  • BITMAP, degrees, center_x, center_y, expand, fill_color (as above).

Output:

  • BITMAP - the rotated bitmap.

Installing

From the Dream Painter pack (comfyui-dream-painter, alt-key-project). ComfyUI Manager β†’ Install Custom Nodes β†’ search Dream Painter β†’ install β†’ restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt

No models, no downloads.

Common issues

The 256,256 center default is the #1 footgun here - on a 1024Γ—1024 bitmap it rotates around the top-left quadrant, and on a small crop it's off-canvas entirely. Get into the habit of reading your size and setting center to half of it. Second: rotating a one-bit image with bilinear resampling introduces gray edges, which then get quantized back to black/white - you may see a slightly chunky outline. For geometry that's fine; for fine detail, prefer rotating the shape with Shape Rotate and re-rendering. And with expand on, remember the canvas size changes (and the bitmap recenters), so re-check your downstream resolution.

CategoryπŸ–Œ DPaint/β–© bitmap

Inputs (6)

NameTypeDefaultDescription
BITMAPBITMAPβ€”
degreesFLOAT45-360–360β€”
center_xINT256β€”
center_yINT256β€”
expandBOOLEANβ€”
fill_colorCOMBO2 options: black, white

Outputs (1)

NameTypeDescription
BITMAPBITMAPβ€”