1. Home
  2. Guides
  3. Why your photo comes out sideways

HEIC · Image formats

Why your photo comes out sideways

Your camera did not rotate the photograph. It saved the image exactly as the sensor read it — usually landscape, because that is how the sensor is mounted — and wrote a single number into the file called the EXIF orientation flag, recording which way up the picture should be displayed. Software that reads the flag rotates the image for you and everything looks right. Software that ignores the flag shows the raw sensor data, which is on its side. Nothing is broken in either case; the two programs simply disagree about whether to honour an instruction. A conversion fixes it permanently by rotating the actual pixels, so the image is upright regardless of what the viewer does.

The camera never rotated your photo

A phone camera sensor has a fixed physical orientation in the body, and it reads out the same way whichever way you are holding the phone. Turn the phone sideways to shoot a portrait and the sensor still produces a landscape image; what changed is your grip, not the hardware.

Rotating those pixels would mean decompressing the image, transforming it, and compressing it again — work the phone would rather not do while you are firing off a burst. So it takes the cheap option. It stores the image as read, consults the accelerometer to work out how you were holding the phone, and writes a number into the metadata describing the rotation needed to display it correctly.

The whole problem follows from that decision. The photograph and the instruction for displaying it are two separate things in the file, and they can be separated.

Need to convert the file?

HEIC to JPG

Eight values, one tag

The flag is EXIF tag 274, and it takes a value from 1 to 8. Value 1 means the image is already the right way up. Value 3 means rotate 180 degrees. Value 6 means rotate 90 degrees clockwise, and value 8 means rotate 90 degrees anticlockwise. Those four cover essentially every photograph you will encounter.

The remaining values — 2, 4, 5 and 7 — describe rotations combined with a mirror flip. They exist for scanners and unusual optical paths and are vanishingly rare in the wild, which is precisely why software that handles them badly can go unnoticed for years.

When a photo appears upside down rather than sideways, you are looking at a value 3 the viewer ignored. When it appears mirrored, something has mishandled one of the rare ones.

Why rotating it in a viewer sometimes does not stick

This is the part that makes the problem feel haunted. You open the sideways photo, rotate it, save it, and it looks correct. You upload it and it is sideways again.

The reason is that many image viewers implement rotation by changing the orientation flag rather than by touching the pixels. It is instant and lossless, which is a genuinely good reason to do it that way. But the file you saved has the same sideways pixels it always had, and all you changed was an instruction that the destination software was already ignoring.

The tell is speed. A rotation that completes instantly on a large photograph almost certainly edited the flag. A rotation that takes a moment and produces a file of a slightly different size actually re-encoded the image.

What a conversion does about it

A conversion decodes the image to pixels and encodes a new file from them, which forces the question: are the pixels being decoded as stored, or as the flag says they should be displayed?

Done properly, the decoder is told to apply the orientation flag, so the pixel grid it produces is already the right way up. The new file is then written from those pixels, upright, with no flag needed — because the rotation is now part of the image rather than an instruction attached to it. That is what the converters here do.

Done carelessly, the decoder ignores the flag and the new file contains sideways pixels and no metadata to explain them. This is worse than the original, because at least the original carried the instruction. It is the single most common way a conversion tool produces visibly wrong output.

Where this still bites

Upload forms and web applications are the classic case. Your browser honours the flag when displaying a preview, so the photo looks correct while you are selecting it, and the server-side code that generates a thumbnail does not, so the version everyone else sees is sideways.

Older desktop software, print services, and anything that processes images in bulk are the other repeat offenders. Document scanning and identity verification systems are particularly unforgiving, because a rotated passport photo is often rejected outright rather than displayed oddly.

The pattern is consistent: the flag is honoured on the device where the photo was taken and increasingly ignored the further the file travels. If a photograph has to survive that journey, bake the rotation in before you send it.

Frequently asked questions

Why is my photo sideways after uploading it?

Because the image data is stored landscape and an EXIF orientation flag says to display it rotated. Your phone honours that flag; the site you uploaded to does not. The file is fine — the two pieces of software disagree about whether to follow the instruction.

I rotated the photo and saved it. Why is it still sideways?

Most viewers rotate by changing the orientation flag rather than the pixels, which is instant and lossless but leaves the underlying image untouched. The destination software was already ignoring that flag, so nothing changed for it.

Does converting fix a sideways photo?

Yes, provided the converter applies the orientation flag when decoding. The rotation gets written into the pixels themselves, so the result is upright everywhere, including in software that reads no metadata at all.

Why do phones store photos this way instead of rotating them?

Because rotating means decoding, transforming and re-encoding the image, which costs time and battery and slightly degrades a lossy file. Writing a number into the metadata costs nothing, so cameras have done it that way for decades.

What is EXIF tag 274?

The orientation flag. It takes a value from 1 to 8: 1 is upright, 3 is 180 degrees, 6 is 90 degrees clockwise, 8 is 90 degrees anticlockwise, and the remaining four describe rotations combined with a mirror flip.

Will stripping metadata make my photo sideways?

It will if the metadata is removed without first applying the orientation flag, because you have deleted the only instruction keeping it upright. Removing metadata after rotating the pixels is safe.