Skip to content
Blog

Why a JPEG turns sideways after upload

The photo looks upright on your phone but sideways in a form. Two arrow images show how to diagnose and fix the rotation.

Open the full-size uploaded image before turning anything. A website may build its thumbnail separately, so a sideways preview doesn't necessarily tell you what the recipient will see.

Which way is up?

Our JPEG stores a 480 × 320 grid of pixels. EXIF Orientation 6 tells a viewer to rotate it 90° clockwise for display. Ignore that instruction, or strip it before rotating the pixels, and the arrow points left.

The raw pixels point left in the source and up in the corrected copy. An EXIF-aware viewer shows both upright.
The raw pixels point left in the source and up in the corrected copy. An EXIF-aware viewer shows both upright.

Make a copy for the form

  1. Keep the original. Export a new JPEG from an editor that honours orientation. If the preview is already upright, leave it there. Rotate it once if it is still sideways.
  2. Check the copy. In our example it should be 320 pixels wide and 480 high, with no rotation needed for display.
  3. ImageMagick can apply the stored orientation before saving. If the tag has already gone, choose the direction yourself.
magick sideways.jpg -auto-orient -quality 92 upright.jpg

Check the uploaded copy

Upload the copy under a fresh name, then reopen the full image. If only the thumbnail cuts off a forehead or the edge of a document, inspect its crop before resizing the original.

Our files measured 15,864 and 13,165 bytes after JPEG export. For a 200 KB limit, rotate and compress in one export from the original.

Files and further reading