You take a photo in portrait. It looks correct on your phone. You upload it, and it arrives on its side.

Nothing was corrupted and nothing rotated it. The photo has been lying on its side the whole time, and your phone was quietly correcting it for you. The upload just removed the correction.

This is one of the oldest and most persistent annoyances in digital photography, and once you understand the mechanism it stops being mysterious and becomes predictable.

Your camera does not rotate the pixels

When you turn your phone sideways to take a landscape shot, the sensor does not turn with the picture. It sits in a fixed position inside the body. Whatever it records comes off the sensor in the same physical arrangement every time, regardless of how you were holding the device.

What the phone does instead is read its accelerometer, work out which way was up, and write that down as a small note attached to the file. The note is called the Orientation tag, and it lives in the EXIF metadata alongside the shutter speed, the date and the lens details.

The pixels are never touched. The file simply carries an instruction: display this rotated 90 degrees clockwise.

There is a good reason for this. Rotating a JPEG properly means decoding it, turning the pixel grid, and encoding it again, which costs time, costs battery, and throws away a little image quality every time it happens. Writing a two-byte flag costs nothing and loses nothing. For a device taking thousands of photos, that is an easy trade.

The flag has eight possible values, and two of them are not rotations

The Orientation tag can hold values from 1 to 8. Value 1 means the image is already the right way up and needs no correction, which covers most photos taken with the phone held normally.

Four of the remaining values describe rotations: a quarter turn one way, a quarter turn the other, or a half turn. These are the common ones, and they are what your phone writes when you shoot in portrait or upside down.

The other values describe something different. They mirror the image, either on its own or combined with a rotation. Mirroring is not a rotation and cannot be achieved by rotating, spin a photograph of a shop sign as much as you like and the writing never comes out the right way round.

Why this distinction matters: if a photo comes out mirrored rather than merely turned, rotating it will never fix it. You need a horizontal flip. That is a different operation, which is why rotating and flipping are separate tools rather than one control.

Mirroring shows up most often with front-facing cameras. Many phones show you a mirrored preview because that is what you are used to seeing in a bathroom mirror, and some then save the file that way. Text in the background reads backwards, and no amount of rotation will recover it.

An ambulance driving down a street with the word AMBULANCE painted in reverse across its bonnet
The lettering on a bonnet is painted mirrored on purpose, so it reads correctly in the rear-view mirror of the car in front. Turn the vehicle any way you like and the word on the bonnet still reads backwards, that is the difference between a mirror and a rotation. Photo: Ingy The Wingy from Bury, Lancashire, Great Britain (CC BY-SA 2.0).

Why some software gets it right and some does not

The flag is only an instruction. Every piece of software that opens the file has to decide whether to obey it.

Your phone's photo app obeys it, which is why the image looks fine before you upload. Desktop photo viewers generally obey it. Professional editing software obeys it.

Where it historically fell apart was the web. For years, browsers displaying an image in an <img> tag ignored the Orientation flag entirely and drew the raw pixel grid exactly as stored. A portrait photo that looked correct everywhere else appeared on its side the moment it was placed on a web page. Browsers now honour the flag by default, and there is a CSS property, image-orientation, that controls the behaviour explicitly.

The stubborn problems are further back in the chain. Server-side image processing (the code that generates thumbnails when you upload to a site) is written by many different people using many different libraries, and a good number of those libraries read the pixels without ever looking at the metadata. The thumbnail comes out sideways while the original looks fine. That mismatch is the classic symptom, and it is not something you can fix from your end.

Stripping metadata can flip your photo

Here is the trap that catches people who are being careful about privacy.

EXIF data can contain GPS coordinates, device serial numbers and timestamps, and there are excellent reasons to remove it before publishing a photo. But the Orientation flag lives in that same block of metadata. Strip everything, and you strip the instruction that was holding the image upright.

The result is a photo that looked perfect until you cleaned it, and is now lying on its side.

The order that avoids this: apply the rotation first so it is baked into the pixels, then remove the metadata. Once the pixels themselves are the right way up, the flag becomes irrelevant and can be discarded safely. If you want to see what is actually in a file before deciding, inspect the metadata first, and our guide to what EXIF data reveals covers the privacy side in detail.

Rotating without losing quality

JPEG is a lossy format. Every time a JPEG is decoded and re-encoded, it goes through the compression process again and loses a little detail. Do it repeatedly and the damage accumulates visibly: soft edges, blotchy areas of flat colour, halos around high-contrast lines.

Rotating a JPEG the naive way costs you one of those cycles.

There is a better method. JPEG stores an image as a grid of small blocks, and a rotation by an exact quarter turn can be performed by rearranging those blocks rather than by decoding the picture. Nothing is recompressed, so nothing is lost. This is usually called lossless JPEG rotation.

It has one condition: the image dimensions need to divide evenly into the block grid. When they do not, the edge strip cannot be rearranged cleanly, and tools either trim a few pixels off the edge or fall back to a full re-encode. Most photos straight out of a camera have dimensions that work.

PNG, WebP in lossless mode, and TIFF do not have this problem at all, they are not lossy, so rotating and saving costs you nothing regardless of dimensions.

Where this bites in practice

The sideways thumbnail on a web page is the harmless version. There are places where it costs real money or real time.

Marketplace listings. Most selling platforms generate their own thumbnails from what you upload. If their pipeline ignores orientation, your product appears rotated in the grid where buyers are scanning quickly, and a rotated product photo reads as a careless seller. The listing may look perfectly fine in your own preview, because your browser is honouring the flag that their thumbnail generator ignored.

Printing. A print service laying out images on a sheet works from pixel dimensions. A portrait photo stored as landscape with a flag will be treated as landscape, and you get a rotated print inside a correctly oriented border, or an unexpected crop.

Documents and forms. Uploading a photographed document (an ID, a receipt, a signed form) to a system that ignores orientation means a human on the other end has to tilt their head or reject the submission. This is a common reason for applications being bounced back.

Anything automated. Optical character recognition, barcode scanning and face detection generally expect an upright image. Feed them a sideways one and results degrade or fail entirely, with no error message that explains why.

A small bubble spirit level clipped into the accessory shoe on top of a compact camera
Before cameras carried motion sensors, photographers clipped a bubble level into the accessory shoe to find level. A phone does the same job electronically, then writes the answer into the file rather than into the pixels. Photo: Ka23 13 (CC BY-SA 4.0).

Working out what went wrong

When an image comes out wrong, the symptom usually tells you where in the chain the problem sits.

What you seeWhat it usually means
Correct on your device, sideways after uploadThe site ignores the orientation flag. Bake the rotation in before uploading.
Correct at full size, sideways as a thumbnailThe site honours the flag when displaying but not when generating thumbnails.
Was correct, went sideways after you edited itMetadata was stripped, taking the flag with it.
Text and logos read backwardsMirrored, not rotated. Needs a flip.
Upside down rather than on its sideA half turn, the phone was held with the camera at the bottom.
Only some photos in a batch are wrongOnly those were shot in a different orientation. The rest had nothing to correct.

That last row explains something that otherwise looks random. If a folder of photos comes back with three out of twenty on their side, nothing selectively corrupted those three, they are simply the ones you shot in portrait, and they are the only ones that ever needed the flag.

Fixing it, and stopping it happening again

If you have a sideways photo in front of you right now, the fix is to bake the correct orientation into the pixels rather than relying on a flag that something downstream might ignore.

  • Work out whether it is turned or mirrored. Look for text, a watch on a wrist, a logo, a parting in someone's hair. If the writing reads backwards, you need a flip, not a rotation.
  • Rotate or flip it so it looks right. You can do this in the browser with our rotate tool, the file stays on your device, which matters if the photo is personal.
  • Save it, then strip metadata if you want to. In that order.
  • Re-upload. With the pixels themselves correct, no downstream software can get it wrong.

To reduce how often it happens in the first place, there are a couple of habits worth having. Exporting from a photo app usually applies the rotation permanently rather than passing the flag along, so a photo that has been through an export is generally safe. And if you are handing a batch of images to someone else (a printer, a designer, a marketplace listing), normalising the orientation before you send them saves an email exchange later.

When the sideways photo is telling you something useful

One last thing, because it occasionally matters.

If an image arrives with its Orientation flag intact, that flag is a small piece of evidence about the file's history. A photo that has been through a screenshot, a re-encode, or certain messaging apps will usually have lost it, along with the rest of its metadata. A photo that still carries a full EXIF block including orientation is more likely to be closer to the original.

That is not proof of anything on its own. Metadata is trivially editable and its absence proves nothing either, since plenty of legitimate platforms strip it automatically. But when you are trying to work out whether the image in front of you is an original or a copy of a copy, it is one more thing to look at.

Mostly, though, it is just a flag that says which way is up, and now you know why your photo keeps ignoring it.