Why Photos Appear Sideways After You Upload Them
The photo is upright in your gallery, upright on your laptop, and lying on its side the moment it lands in a CMS, a support ticket or someone's old email client. Nothing is wrong with the picture. The rotation was never in the pixels to begin with.
The camera stores a note, not a rotated image
A camera sensor has a fixed shape — usually wider than it is tall. When you hold the phone upright, the sensor still captures a landscape frame; it is just turned 90° relative to the world. Rotating millions of pixels on every shot would cost time and battery, so cameras save the frame as captured and add a single number to the EXIF metadata: the Orientation tag, telling viewers how to turn the image for display.
Software that reads the tag shows the photo correctly. Software that ignores it shows the raw sensor frame — sideways.
The eight orientation values
| Value | To display correctly | Typical cause |
|---|---|---|
| 1 | Nothing — already upright | Phone held in landscape, the sensor's natural way round |
| 3 | Rotate 180° | Landscape, turned the other way |
| 6 | Rotate 90° clockwise | Phone held upright (portrait) — the most common |
| 8 | Rotate 90° counter-clockwise | Portrait, held upside down |
| 2, 4, 5, 7 | Mirror, plus a rotation for 5 and 7 | Rare; some front cameras and editing apps |
So a "sideways" portrait photo is almost always an orientation-6 image whose tag was ignored or lost. You can check what a file carries with an EXIF viewer.
Where it still goes wrong
Browsers used to be the main culprit: for years, an <img> ignored the tag. Since 2020 Chrome, Firefox and Safari all honour it by default (the CSS image-orientation: from-image behaviour). The problem moved to the steps between your camera and the screen:
Metadata stripped, rotation not applied
The classic. An upload pipeline removes EXIF for privacy or size — good — but does not rotate the pixels first. The note is gone and the frame is still sideways. Many resize scripts do exactly this.
Rotated twice
An editor rotates the pixels but copies the original Orientation tag into the new file. Any viewer that respects the tag now turns an already-upright image a second time.
Older or minimal software
Some email clients, document tools, printers and embedded systems still read pixels only.
Your own code
Image libraries differ on whether they apply the tag when decoding. A thumbnail generator can be silently wrong while the original displays fine.
The real fix: bake the rotation into the pixels
The durable answer is to rotate the pixels to match the tag and then reset or remove the tag, so every viewer — careful or careless — sees the same upright image. In a browser, the Rotate & Flip Image tool reads the tag, shows you the photo the right way up, and exports a file where the rotation is in the pixels and no tag is left to misread. You can also straighten a tilted horizon there while you're at it.
If you process images in code, every major library has a one-line "auto-orient":
# Python (Pillow)
from PIL import Image, ImageOps
img = ImageOps.exif_transpose(Image.open("photo.jpg"))
img.save("upright.jpg", quality=90)
# ImageMagick
magick photo.jpg -auto-orient upright.jpg
# Node.js (sharp) — rotate() with no angle applies the EXIF tag
await sharp("photo.jpg").rotate().toFile("upright.jpg"); Run auto-orient before you strip metadata or resize. Done in that order, the problem cannot reach your users.
What not to do
- Don't just set the tag to 1 unless you have also rotated the pixels. That converts "displays correctly in most places" into "displays sideways everywhere".
- Don't rotate by eye in a tool that keeps the old tag. It will look right in that tool and wrong in the next one. Check the exported file in a second viewer.
- Don't rotate JPGs repeatedly. Each save re-compresses. 90° steps in some tools are lossless, but most browser and phone editors re-encode; rotate once, from the original.
Fix a sideways photo for good — free, in your browser