How Arbitrary-Angle Rotation Computes Expanded Canvas Bounding Boxes
Trigonometric width/height projection formulas (`w·cos θ + h·sin θ`) that keep rotated corners from ever clipping off-canvas.
Primary Browser Tool
Image Rotator
Rotate images cleanly by 90°, 180°, or 270° increments or apply fine custom-degree straightening.
Avoiding Corner Clipping During Rotation
Rotating a rectangle by angle `θ` widens its axis-aligned shadow to `|w·cos(θ)| + |h·sin(θ)|` wide by `|w·sin(θ)| + |h·cos(θ)|` tall. RapidPNG expands the destination canvas to those exact trigonometric bounds before applying `ctx.translate(outW/2, outH/2)` and `ctx.rotate(rad)`, keeping all four original image corners completely intact.
Practical Examples
1000 × 1000 Square Rotated 45°
Expanded canvas grows to `1414 × 1414` (`1000 × √2`) so diagonal corners never get sliced off.
Common Mistakes & Honest Limitations
Mistakes to Avoid
- Expecting rotated dimensions to stay 1000×1000 while keeping full tilted corners.
Technical Limitations
- Arbitrary angles between 90° increments rely on bilinear/bicubic resampling on Canvas.