Image Compressor topic guide

Why is my photo sideways: EXIF orientation explained

Direct answer

A phone camera usually writes the sensor image in landscape and adds an Orientation tag telling software how far to turn it. The pixels never moved. When an app rotates the picture back into portrait, it may be following that tag rather than changing the file. Strip the tag and the landscape pixels reappear — which is why a photo that looked upright can arrive sideways after a resize or a compression step.

Try the Image Compressor

Check this first

  1. Dimensions are portrait — Open the file properties. A corrected portrait shot from a 4032 by 3024 sensor reads 3024 by 4032. If the numbers are unchanged, only the tag was edited.
  2. Orientation tag is 1 or gone — exiftool -Orientation -n should print 1 or nothing. A value of 6 or 8 next to already-rotated pixels is the setup for a double rotation later.
  3. Upright in a viewer that ignores EXIF — Open the file in a tool that does not read metadata, or strip a copy and look at it. If both copies match, the pixels themselves are correct.
  4. Thumbnail agrees with the full image — Some editors keep an old embedded thumbnail. Compare the thumbnail with the full-size view; a mismatch means the file was only partly rewritten.

What this workflow handles

Orientation is one of the tags defined by the CIPA Exif standard, and the current edition is Exif 3.1, published as CIPA DC-008-Translation-2026. The tag holds one of eight values. Value 1 means the image is already upright. Value 3 is 180 degrees. Value 6 is 90 degrees clockwise and value 8 is 90 degrees counter-clockwise; those two cover most portrait phone shots. Values 2, 4, 5 and 7 are mirrored variants, which is why some front-camera photos look reversed even when they are the right way up. Browsers now follow the tag by default: MDN documents image-orientation with from-image as the initial value and reports broad support since April 2020. That default is why the problem hides. The page looks correct while the file is only correct because of metadata. Any step that drops metadata — a screenshot, a canvas re-encode, some upload pipelines, a resizer that rebuilds the file — leaves the raw pixels behind. The opposite failure is just as common: one tool applies the rotation and keeps the tag, the viewer applies it again, and the photo ends up on its side or upside down. The reliable fix is to apply the rotation to the pixels and remove the tag, which is exactly what Pillow's ImageOps.exif_transpose documents: if the tag is present and not 1, transpose the image and remove the orientation data.

Use the image compressor to re-encode a single image in its original format at the same pixel dimensions, then compare the byte counts in the result panel before keeping the output.

How to use it

  1. Read the tag before touching the file. exiftool -Orientation -n photo.jpg prints the numeric value, and -Orientation prints the label. Compare that with what your editor shows.
  2. Apply the rotation to the pixels, not to the preview. In Pillow that is ImageOps.exif_transpose(image); in a desktop editor it is the command that applies or flattens rotation rather than the one that only sets an orientation flag.
  3. Check the dimensions after saving. A 4032 by 3024 landscape file becomes 3024 by 4032 when the rotation is baked in, and the change is the quickest proof that the pixels moved.
  4. Open the saved file in two different viewers, including one that ignores EXIF. If both show it upright, the fix is in the file rather than in the viewer.
  5. Resize or compress only after the rotation is baked in, so later steps cannot reintroduce the mismatch.

Common mistakes

  • Rotating the preview and assuming the file changed. Many galleries and viewers rotate only the display. The file on disk keeps landscape pixels and the original tag. Copy it into another tool and the old orientation returns. Check the saved dimensions after rotating; if width and height did not swap, the pixels did not move.
  • Stripping metadata before applying the orientation. Removing EXIF to reduce file size or protect privacy also removes the instruction that keeps the photo upright. If you need a metadata-free file, transpose the pixels first and remove the tag second, in that order. The reverse order produces a landscape photo with no way to recover the intended orientation.
  • Applying the rotation twice. When a tool rotates the pixels but leaves the tag set to 6 or 8, the next viewer rotates again and the photo lands on its side. The tag should be 1, or absent, after the pixels have been corrected. If a file looks wrong only in one app, this is the first thing to check.
  • Cropping while the file is still tag-rotated. Crop coordinates refer to the grid the tool is showing, which may be the rotated view rather than the stored pixels. A crop that looks centred on screen can land in the wrong corner of the raw image. Bake the rotation in first, then crop.

Frequently asked questions

Why is my photo sideways after uploading?

The upload pipeline dropped the EXIF Orientation tag before the browser saw the file. The pixels were always landscape; the tag was the only thing telling the viewer to turn them. Once the tag is gone, the browser follows its default behaviour and shows the raw orientation. The fix is to bake the rotation into the pixels before that step, not to rotate the preview.

Does rotating the photo in Photos or on Windows fix the file?

It depends on what the app writes. Some viewers only update the orientation tag, which fixes the display and leaves the pixels untouched; the next tool that ignores or strips metadata brings the problem back. Use a command that applies the rotation and saves the result, then confirm the width and height have swapped.

What do the EXIF orientation values mean?

The CIPA Exif standard defines eight. 1 is upright, 3 is 180 degrees, 6 is 90 degrees clockwise and 8 is 90 degrees counter-clockwise. 2, 4, 5 and 7 are mirrored variants. Values 6 and 8 account for most portrait phone photos, while the mirrored values explain why some selfies look reversed.

Why did my photo rotate after I compressed it?

The compressor rebuilt the file and did not carry the orientation tag across, or it carried the tag while the pixels had already been rotated once. Both cases end with a mismatch between pixels and metadata. Applying the rotation first and removing the tag before compression prevents the second rotation from happening at all.

How do I fix a sideways photo permanently?

Apply the rotation once, save the file, and remove the orientation tag in the same step. Pillow's ImageOps.exif_transpose does both, and most editors do the same when you apply rather than preview a rotation. After that, the image no longer depends on metadata to look right.

Sources

Explore the image compressor topic cluster

Each guide answers a different image-decision question. Pick the one that matches your situation, then use the linked tool to produce the output you need.

Related guides

  • Crop vs resize: how to fit an image into a target shape

    Crop keeps the target pixel dimensions and removes pixels at the edges of the source; resize keeps all of the source pixels and fits them into the target by scaling. A third option - letterbox - keeps all of the source and adds padding so the target aspect ratio is preserved. Pick by what the destination needs the image to do, not by which sounds simpler. Backed by the Pillow documentation, MDN and platform specs.

  • Resize vs Compress: which one actually shrinks your image

    Resizing changes the pixel dimensions of an image; compression keeps the dimensions and re-encodes the file at a smaller byte count. Pick resize when the source is larger than the display size, and compression when the dimensions are right but the bytes are still too high. Backed by Chrome for Developers' two Lighthouse audits and the Pillow documentation.

  • Why does my image look blurry on my website

    An image looks blurry on a website when the pixels served are fewer than the slot needs (browser scaling, missing 2x retina file), the source was upscaled, the wrong format was used for the content, or the encoder removed fine detail. A troubleshooting guide that maps each cause to a check and a fix, with sources from MDN, web.dev, Chrome for Developers and the Pillow handbook.

  • JPEG vs PNG vs WebP: how to choose the right image format

    JPEG, PNG and WebP are not interchangeable. The right choice depends on what is in the image, whether it needs transparency, the file-size budget, and where the image will be displayed. A practical decision guide backed by MDN, Google Developers, web.dev, the WHATWG HTML Living Standard and the Pillow documentation.

All image compressor guides