The stored picture and the instruction are separate
A camera file can keep its stored pixel order and use an EXIF Orientation tag to tell a viewer how to turn or mirror it, as the Exif standard defines. A browser preview can therefore look right while the stored image is still sideways, and an export that drops the tag without turning the pixels exposes the difference. We tested the tag on its own first, then repeated the failure with a photograph.
The photograph after an upload-style export
For the photograph we made a 480 × 320 copy of a beach JPEG from Pexels, rotated its stored pixels anticlockwise and added Orientation 6. The file stored 320 × 480 pixels, but the tag made Chrome show a 480 × 320 beach view. The photo was not shot with this tag; we added it to reproduce the problem.
We then made two exports. ExifTool removed all metadata from one copy without rotating the stored image. For the other, jpegtran rotated the JPEG clockwise and removed the metadata; we chose a size whose block boundaries let the tool's -perfect option succeed.
| Photograph | File bytes | Stored dimensions | Chrome display dimensions |
|---|---|---|---|
| Sideways pixels, Orientation 6 | 73,697 | 320 × 480 | 480 × 320 |
| Metadata removed only | 73,579 | 320 × 480 | 320 × 480 |
| Rotated upright, then untagged | 72,993 | 480 × 320 | 480 × 320 |
Removing the metadata saved 118 bytes and broke the intended orientation. The rotated export was also smaller, but that difference includes the transform and Huffman optimization, not just the removed tag.
Orientation 6

Metadata removed

Rotated, then untagged

Rotation and metadata removal are separate operations
EXIF Orientation describes how the stored rows and columns should be presented; the stored image does not have to be in that position already. The tag can also ask for a reflection, as four rows of the table show.
The default CSS image-orientation value is from-image, and CSS Images applies it to CSS images such as backgrounds as well. Our Chrome results followed that rule; the background was not an exception.
Canvas deserves its own check. In our test, drawing the loaded image into a canvas used the oriented image, and the canvas size followed the intrinsic dimensions Chrome reported. A pipeline that rotates an image again after an orientation-aware decode turns it twice, so inspect the decoded dimensions and output rather than assuming your own code must apply the tag.
Check the file before fixing it
We used these ExifTool arguments on the tagged and exported photographs:
exiftool -n -Orientation -ImageWidth -ImageHeight photo.jpgThe -n flag prints the numeric value, which you can match to the table. The tagged photograph returned Orientation 6, ImageWidth 320 and ImageHeight 480. The metadata-only export had the same dimensions and no Orientation result: a missing tag did not mean the picture had become upright.
Read the copy downloaded from the destination, not just the file you picked in the upload dialog, and compare its tag and dimensions with the original. In the browser, check both naturalWidth and naturalHeight; a CSS width alone does not show how the decoder interpreted the photograph.
For a general export, we also ran this ImageMagick command on the Orientation 6 file:
magick photo.jpg -auto-orient -strip -quality 94 corrected.jpgIt produced a 480 × 320 file with no orientation tag. The order matters: -auto-orient needs the tag before -strip removes it. The command writes a new JPEG and can recompress it, so keep the original and inspect the result before replacing anything.
For this specific value 6, our lossless JPEG transform was:
jpegtran -copy none -optimize -perfect -rotate 90 \
-outfile upright.jpg photo.jpgThat only handles a clockwise quarter turn; other values need a different transform or a reflection. -perfect refuses a transform the JPEG block layout cannot perform exactly, so check its exit status instead of accepting a trimmed edge.
When Bitinz compresses a JPEG, it keeps the Orientation tag, so a tagged photo still displays upright; our Orientation 6 test file kept its tag. Colour profiles are the other metadata worth checking after an export; see the colour profile test. If a form also rejects the file for its size, this guide to upload limits covers that part.
What we did not test
We tested one Chrome version through three loading paths. Other browsers and older versions were outside this test, so the table is not a compatibility history.
FAQ
- Why is my photo upright in the browser but sideways after export?
- Check the Orientation tag and stored dimensions in both files. If the original needs a tag and the exported copy has lost it, orient a fresh copy while the tag is still there, then export it with the tag removed or set to 1.
- Can I fix a sideways image by setting Orientation to 1?
- Only if its stored pixels are already upright. Changing the tag does not rotate pixels. Open a correctly interpreted source, export it with an orientation-aware tool and check the result without relying on the old tag.
- Will a CSS rotation repair the uploaded file?
- It changes how that one page presents the image, not the JPEG itself. If the file must work elsewhere, prepare an upright copy instead of depending on a page's transform.
Tools in this guide
Sources
- Bitinz: Orientation test: files, measurements and commands (2026-11-16)
- CIPA: Exif 2.32, section 4.6.4: Orientation
- ExifTool: EXIF tags: Orientation values
- W3C: CSS Images Module Level 3: image-orientation
- MDN: image-orientation
- WHATWG: HTML Standard: drawing images to the canvas
- ImageMagick: Command-line options: -auto-orient
- libjpeg-turbo: jpegtran usage
