# Rotate and Flip an Image Online: 90 Degrees, Any Angle, Mirror

Page: https://hirantha.me/tools/image-rotate-flip
Part of: Hirantha Sandaruwan Lakshan free tools (https://hirantha.me/tools)
Updated: 2026-10-15

Rotate a photo 90, 180 or any angle, flip it left to right or top to bottom, preview it live and save it as PNG, JPEG or WebP. Nothing is uploaded.

This is a free tool that runs in the browser: open the page to use it. File tools process files on the visitor's own device; files are never uploaded or stored. No account, sign-up, payment or watermark.

Turn a picture 90 degrees left or right, 180 degrees, or by any angle you type, and flip it left to right or top to bottom. The preview updates as you click, and you can combine the steps in any order. Save the result as PNG, JPEG or WebP; the file keeps its name with a suffix such as -rotated. Everything happens in your browser, so the photo never leaves your device.

Every mix of turns and mirror images reduces to one of two things: a rotation by some angle, or a left-to-right mirror followed by a rotation. The tool keeps just that pair, and each button updates it. A turn adds to the angle. Flip horizontal switches the mirror and reverses the angle. Flip vertical switches the mirror and sets the angle to 180 minus the angle, because a top-to-bottom mirror is a left-to-right mirror plus a half turn. So flipping left to right and then top to bottom gives a half turn, exactly as it should.

The picture is drawn with a 2D transform matrix, the same six numbers a, b, c, d, e, f that canvas setTransform takes: a point (x, y) goes to (ax + cy + e, bx + dy + f). The matrix keeps the centre of the picture at the centre of the output, so turning never shifts it. For a free angle the canvas grows to the bounding box, |w cos t| + |h sin t| wide and |w sin t| + |h cos t| high, rounded up. You can instead keep the original size and let the corners be cut off, or fill the empty corners with a colour. A quarter turn or a flip puts every pixel exactly on the pixel grid, so nothing needs blending.

Phone photos are often stored sideways with an EXIF orientation tag that tells viewers to turn them. This tool opens files with createImageBitmap, whose imageOrientation option defaults to from-image (MDN), so the tag is applied when the file is decoded and the size and preview match what you see in a gallery. The saved file is drawn from a canvas, so it carries no orientation tag and will not turn a second time in another app. In MDN browser-compat-data the imageOrientation option is in Chrome 52, Firefox 93 and Safari 15 or newer (checked on 2026-10-15).

Canvases have size limits that differ by browser and device, and browsers give no error when you go over. The canvas-size project's test results list 16,384 x 16,384 pixels (268,435,456) for desktop Chrome and Safari, 23,168 x 23,168 for Firefox 122 and newer, and 4,096 x 4,096 (16,777,216) for Mobile Safari, and say that each browser and platform combination has its own limits. This tool works out the output size before it draws. It uses 16,384 pixels per side and 268,435,456 pixels as its desktop ceiling and 4,096 per side and 16,777,216 pixels on phones and tablets, and tells you when it had to scale the result down. JPEG and WebP quality is the 0 to 1 quality of canvas toBlob; PNG is lossless.

What each button does to a picture whose pixels read 1 2 3 on top and 4 5 6 below:
| Action | Result size | Rows of the result |
| --- | --- | --- |
| Rotate right 90° | 2 × 3 | 4 1 / 5 2 / 6 3 |
| Rotate left 90° | 2 × 3 | 3 6 / 2 5 / 1 4 |
| Rotate 180° | 3 × 2 | 6 5 4 / 3 2 1 |
| Flip horizontal | 3 × 2 | 3 2 1 / 6 5 4 |
| Flip vertical | 3 × 2 | 4 5 6 / 1 2 3 |
| Flip horizontal, then rotate right 90° | 2 × 3 | 6 3 / 5 2 / 4 1 |

Q: Will rotating a JPEG lower its quality?
A: Saving as JPEG or WebP compresses the picture again, so a small loss is possible each time. This tool redraws the picture and re-encodes it; it does not do the special lossless JPEG rotation some desktop programs offer. Save as PNG for a lossless result, or keep the quality slider high.

Q: Why does my phone photo look sideways in some programs but right here?
A: Phones often store the pixels sideways and add an EXIF orientation tag. Programs that read the tag show the photo upright; programs that ignore it show it sideways. Here the browser applies the tag when it opens the file, and the saved file has no tag, so the pixels themselves are upright and every program agrees.

Q: Can I rotate by an exact angle such as 15.5 degrees?
A: Yes. Type the angle in the box or drag the slider. Positive numbers turn the picture clockwise and negative numbers anti-clockwise, from -180 to 180 degrees, and decimals are accepted. The buttons add to the angle you have set.

Q: What happens to the empty corners when I rotate by a free angle?
A: By default the canvas grows so nothing is cut off, and the new corners are transparent in PNG and WebP. Pick a fill colour to paint them. JPEG cannot be transparent, so a transparent fill is saved white for JPEG. Or choose Keep size, which stays at the original width and height and cuts the corners off.

Q: Is there a maximum image size?
A: Browsers limit how large a canvas can be, and the limits vary by browser, device and memory. This tool plans the size first. If the rotated result would be too large for your device, the saved file is scaled down and the page says what size it used. This tool's ceiling on a phone or tablet is 4,096 x 4,096 pixels.

Q: What is the file called when I save it?
A: The original name without its extension, then a suffix and the extension of the format actually written: -rotated, -flipped, -edited when you combine a mirror with another angle, or -copy if nothing was changed. IMG_0042.jpg saved as PNG after a turn becomes IMG_0042-rotated.png.

Q: Does it work on animated GIFs?
A: Only the first frame is used, and the saved file is a still picture. The page warns you when it detects an animated GIF, WebP, PNG or AVIF.

Q: Can I rotate a HEIC photo from an iPhone?
A: Convert it to JPG first with the HEIC to JPG tool on this site. Most browsers cannot draw HEIC on a canvas, so this tool says so instead of failing silently.

Q: Is my photo uploaded anywhere?
A: No. The file is opened and redrawn inside your browser tab and never sent over the network.

Sources: createImageBitmap() - MDN (https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap); image-orientation - MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/image-orientation); CanvasRenderingContext2D.setTransform() - MDN (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform); HTMLCanvasElement.toBlob() - MDN (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob); canvas-size: maximum canvas dimensions and test results (https://jhildenbiddle.github.io/canvas-size/)

Related tools:

- [Crop an image](https://hirantha.me/tools/image-crop.md): Crop a photo to any rectangle, with optional aspect ratio presets.
- [Resize an image](https://hirantha.me/tools/image-resize.md): Resize a photo by percentage, or an exact width or height.
- [Image filters and adjustments](https://hirantha.me/tools/image-filters.md): Adjust brightness, contrast, saturation, hue, grayscale, sepia, invert and blur with a live before and after view. Same result in every browser.
- [Remove EXIF data](https://hirantha.me/tools/remove-exif.md): Strip location and camera metadata from a photo before sharing it.
- [HEIC to JPG](https://hirantha.me/tools/heic.md): Convert iPhone photos so they open anywhere.
