How 2D Matrix Image Rotation, Mirroring & Bounding-Box Expansion Work
Fixing Sideways Phone Scans, Reversed Selfies & Tilted Horizon Lines
Smartphones and document scanners frequently embed orientation flags inside EXIF metadata rather than rotating the underlying pixel grid—causing scanned IDs, certificates, or portrait photos to appear sideways or upside down when uploaded to web portals. Similarly, front-facing selfie cameras capture horizontally mirrored images where text on clothing or signs appears backward. Our browser-based Rotate & Flip Image tool applies true 2D affine matrix transformations directly onto an HTML5 Canvas—permanently baking your 90°, 180°, fine-angle straighten, or horizontal/vertical mirror adjustments into a clean, universally compatible JPG, PNG, or WebP file.
How to Rotate or Flip Any Image in 3 Easy Steps
- Upload Your Photo: Drag and drop any JPG, PNG, or WebP file into the workspace above—processing happens 100% locally in your browser.
- Rotate or Mirror Instantly: Click Rotate Left 90°, Rotate Right 90°, 180°, Flip Horizontal, or Flip Vertical—or drag the Fine Straighten slider to level tilted horizons.
- Choose Format & Download: Select JPG, PNG, or WebP and click Download Transformed Image.
2D Rotation Bounding-Box Formula & Worked Example
When an image of width W and height H is rotated by an arbitrary angle θ, the canvas expands to fit all four rotated corners without clipping edges:
Wnew = |W × cos(θ)| + |H × sin(θ)| | Hnew = |W × sin(θ)| + |H × cos(θ)|
Worked Example: Suppose you upload a landscape scanned document measuring 1600 × 1200 px and rotate it 90° clockwise.
Since cos(90°) = 0 and sin(90°) = 1: Wnew = |1600 × 0| + |1200 × 1| = 1,200 px and Hnew = |1600 × 1| + |1200 × 0| = 1,600 px.
The exported file is a crisp portrait 1200 × 1600 px image with zero cropped corners.
Image Orientation, EXIF Tags & Transformation Reference Chart (16 Cases)
Use this technical reference chart to understand standard camera orientation tags, mirror transformations, and output dimensions.
| Transformation / EXIF Tag |
Angle / Axis |
Dimension Change |
Common Real-World Scenario |
| Rotate Right 90° (CW) |
+90° Clockwise |
W ↔ H Swapped |
Fixing sideways landscape phone scans |
| Rotate Left 90° (CCW) |
-90° Counter-Clockwise |
W ↔ H Swapped |
Correcting rotated portrait receipts |
| Rotate 180° (Invert) |
180° Half-Turn |
W × H Unchanged |
Fixing upside-down scanner documents |
| Flip Horizontal (Mirror X) |
Left ↔ Right Axis |
W × H Unchanged |
Un-mirroring front-camera selfies & text |
| Flip Vertical (Mirror Y) |
Top ↔ Bottom Axis |
W × H Unchanged |
Creating water reflection effects & transfers |
| Fine Straighten (-5° to +5°) |
Small Tilt Correction |
Slightly Expanded Box |
Leveling crooked horizon lines in photos |
| Diagonal 45° Rotation |
45° Angle |
~1.414× Square Box |
Diamond badge & social graphic layouts |
| EXIF Orientation = 1 |
0° Normal |
Standard Top-Left |
Universal web-safe orientation |
| EXIF Orientation = 3 |
180° Rotated |
Upside Down |
Baked permanently on export |
| EXIF Orientation = 6 |
90° CW Needed |
Portrait stored sideways |
Common on iPhone & Android cameras |
| EXIF Orientation = 8 |
270° CW (-90°) |
Portrait stored sideways |
Fixed permanently via Rotate Left 90° |
| T-Shirt Iron-On Transfer Print |
Flip Horizontal |
Mirrored X-Axis |
Ensures text reads forward after heat press |
| JPG Export Canvas Fill |
#FFFFFF White BG |
Opaque Corners |
Fills angled corner triangles cleanly |
| PNG Export Canvas Fill |
Transparent Alpha |
RGBA Transparency |
Keeps angled corners transparent |
| WebP Export Format |
Modern Web Raster |
~30% Smaller than JPG |
Fast loading for websites & blogs |
| Processing Privacy |
HTML5 Canvas 2D |
100% Client-Side |
Zero server uploads for personal IDs |
Need to crop your rotated image to a 1:1 or 16:9 frame, resize pixels, or compress under 50 KB? Explore our companion tools: