Metadata
Why Your Photos Are Sideways, and How to Fix EXIF Rotation
A photo that looks upright in your phone’s gallery but sideways in a browser is not corrupted. The pixels are almost certainly stored in landscape orientation, and the file carries a small EXIF tag that tells the viewer to rotate it. Some viewers obey the tag. Some ignore it. Some apply it twice. The result is the same image appearing in three different orientations depending on where you open it.
What the orientation tag does
EXIF is a metadata block that cameras and phones write into JPEG, and sometimes into PNG or WebP. Among its fields is Orientation, tag 0x0112. It has eight defined values:
| Value | Meaning |
|---|---|
| 1 | Normal, no rotation |
| 2 | Mirrored horizontally |
| 3 | Rotated 180 degrees |
| 4 | Mirrored vertically |
| 5 | Mirrored horizontally, then rotated 270 degrees clockwise |
| 6 | Rotated 90 degrees clockwise |
| 7 | Mirrored horizontally, then rotated 90 degrees clockwise |
| 8 | Rotated 270 degrees clockwise |
When you hold a phone in portrait, the sensor may still capture a landscape frame. The phone writes the pixels as the sensor saw them and records value 6 or 8 to describe how the image should be turned for display. The file’s pixel dimensions stay landscape; the tag supplies the missing instruction.
Why the same file looks different everywhere
Modern browsers, operating systems, and image libraries generally honor the tag. Older software, some upload pipelines, and a few thumbnail generators ignore it. A website may strip metadata on upload and keep the unrotated pixels, which is why a photo can look correct on your phone and sideways on a marketplace listing.
The problem compounds when an application applies the rotation visually but saves the file without normalizing it. If the tag is applied once for display and then applied again during export, the image ends up rotated 180 degrees. That is the classic “it was fine until I edited it” case.
The permanent fix is to bake the rotation into the pixels
There are only two ways to make an image consistently upright:
- Rewrite the pixels in the correct orientation and remove the tag. Every viewer then sees the same thing, including software that ignores EXIF.
- Keep the tag and hope every destination honors it. This is not a fix, it is a compatibility bet.
Baking the rotation requires decoding the image with orientation applied and encoding a new file. That is exactly what a browser canvas does when it is told to respect the source orientation. The output has the correct pixel dimensions, the image is upright, and the orientation tag is gone because the new file has no EXIF block at all.
The cost is the rest of the metadata. A re-encode also drops camera model, lens, exposure settings, capture date, copyright, and GPS coordinates. For a photo going to a client or a public listing, that is often an improvement. For an archival master, keep the original and make the upright copy separately.
Fix it with the editor
The editor is the right place when the image needs more than a rotation, or when you want to inspect it before exporting.
- Open the editor and load the photo.
- Look at the image before touching anything. If it appears upright, the editor has already applied the orientation tag. Do not rotate it again.
- If it appears sideways, use the image rotation command to turn it 90 degrees in the correct direction. Rotate clockwise if the top of the subject points left; counter-clockwise if it points right.
- Check the result against a known reference, such as text in the scene or a horizon.
- Export as JPEG or PNG. The export writes new pixels and does not carry the original EXIF block.
- Open the exported file in a different viewer, or upload it to the destination, and confirm it is still upright.
Step 2 is the one people skip. Rotating an image that the editor already corrected produces a file that is wrong by 90 degrees in the opposite direction.
Fix it during compression or resizing
The compressor and the resizer decode with the orientation applied, then encode a new file. If you only need the photo upright and smaller, this is the shortest path: add the file, set the target size or dimensions, and export. The result is upright because the rotation was applied before encoding, and the tag is gone because the encoder does not write EXIF.
This is also why a compressed photo can look different from the original in a file browser that ignores orientation. The compressed copy is the one with normalized pixels. The original still depends on the viewer. One exception: when the compressor reports a file as already optimal and returns the original, the metadata and the orientation tag are still there, because no re-encode happened.
What you cannot do here
Lossless rotation is a different operation. Tools such as jpegtran can rotate a JPEG by 90-degree increments without re-encoding the image data, and they can preserve the rest of the EXIF block. That is useful for archival work where every re-encode is unacceptable. This site does not offer lossless rotation; every output is a fresh encode. If preserving the original metadata is a hard requirement, use a dedicated metadata tool and keep this site for delivery copies.
There is also no way to recover detail that was lost when the photo was taken. Rotation only changes orientation. It does not improve resolution, sharpness, or exposure.
GPS and privacy
The orientation tag is harmless. The GPS fields in the same EXIF block are not. A phone photo taken at home can carry coordinates accurate enough to identify the building. When you post an image publicly, stripping metadata is a privacy measure, not just a side effect.
A browser re-encode removes GPS along with everything else. That is a reason to prefer exporting through a tool that writes new pixels rather than uploading the camera original. It is also a reason to check what a platform does with metadata before assuming it has been removed; some platforms preserve it, some strip it, and the behavior can change.
If you need to keep GPS for a private archive, retain the original file and publish only the stripped copy. Do not rely on the published copy as your master.
Diagnosing a stubborn file
If a photo still looks wrong after an export, check these in order:
- Did the tool actually re-encode it? A file that was only renamed or copied keeps its original tag and pixels.
- Was the rotation applied twice? Compare the exported image with the original in a viewer known to honor EXIF. If the original is upright and the export is 180 degrees off, the editor applied the tag and you rotated on top of it.
- Is the destination stripping metadata? Upload the exported file somewhere neutral and open it in a browser. If it is upright there but sideways in the destination, the destination is doing something unusual.
- Is the source a PNG or WebP? Orientation tags are less consistently written and read in those formats. A re-encode is still the reliable fix.
The short version
The pixels are probably fine. The instruction that describes how to turn them is the fragile part. Decode with orientation applied, save a new file, and the ambiguity disappears. Accept that the new file loses the camera metadata, including GPS, and keep the original if you need it. For a batch of photos that all need the same treatment, the compressor can normalize orientation and hit a size target in one pass.