Rotate an image by an arbitrary angle while preserving its visible bounds.
The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.
Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.
The canvas coordinate system is translated to the output center, rotated by the requested angle, and the source bitmap is drawn around the transformed origin. The output canvas is expanded for quarter-turns or bounding-box fit so pixels are not clipped.
data:image/png;base64,iVBORw0KGgo=
PNG with width and height exchanged after a clockwise quarter-turn
Scanned-page correction, photo editing, and sprite pipelines rotate images.