EXIF Orientation and Image Rotation: Why Your Photos Display Sideways and How to Fix It
Your phone always stores photos in landscape pixel order and writes a rotation tag into the metadata. When software ignores that tag, photos appear sideways or upside down. Here's how EXIF orientation works, what the eight possible values mean, and why this problem still exists in 2026.
You take a portrait photo on your phone, send it to someone, and they tell you it arrived sideways. You upload a headshot to a website and it displays rotated 90 degrees. You embed an image in a PDF and it is upside down. You have encountered one of the most persistent and frustrating problems in digital imaging: the EXIF orientation mismatch.
The problem exists because of a design decision made decades ago. When a digital camera captures a photo, the image sensor always reads pixels in the same order — left to right, top to bottom — regardless of how the camera is held. A portrait photo (camera held vertically) is stored with the same pixel arrangement as a landscape photo (camera held horizontally). The only difference is a small metadata tag embedded in the file that tells viewing software how to rotate the image for correct display. When the software reads and respects that tag, the photo looks right. When the software ignores it — and many tools still do — the photo appears sideways or upside down.
This article explains the EXIF orientation system, the eight possible orientation values, why the mismatch problem persists, and how to fix it permanently by baking the rotation into the pixel data.
What EXIF Is
EXIF (Exchangeable Image File Format) is a standard for metadata embedded in image files — primarily JPEG and TIFF. It was developed by the Japan Electronic Industries Development Association (now JEITA) and first published in 1995. EXIF metadata records information about how the photo was taken: camera model, lens focal length, aperture, shutter speed, ISO, GPS coordinates, date and time, white balance, and — critically for our purposes — the orientation of the camera at the moment of capture.
The EXIF data is stored as a block of bytes at the beginning of the JPEG file, before the image data itself. It follows the TIFF directory structure, with each piece of metadata identified by a numeric tag. The orientation tag is tag number 274 (0x0112 in hexadecimal).
EXIF is supported by JPEG and TIFF files. PNG files do not support EXIF (though a related standard, Exif-in-PNG, exists but has minimal adoption). WebP supports EXIF metadata. When you convert an image from JPEG to PNG using a format converter, the EXIF metadata — including the orientation tag — is typically stripped, which can actually fix orientation problems by forcing the tool to bake the rotation into the pixel data before saving.
The Eight Orientation Values
The EXIF orientation tag has eight possible values, each describing a combination of rotation and mirroring needed to display the image correctly. The values describe the relationship between the stored pixel order and the intended display orientation.
Value 1: Normal. The pixel data matches the intended display. Row 0 is at the visual top, column 0 is at the visual left. No transformation needed. This is the orientation of a standard landscape photo taken with the camera held normally.
Value 2: Mirrored horizontally. The image is flipped left-to-right. Row 0 is at the top, but column 0 is at the visual right instead of the left. To display correctly, flip the image horizontally.
Value 3: Rotated 180 degrees. The image is upside down. Row 0 is at the visual bottom, column 0 is at the visual right. To display correctly, rotate 180 degrees.
Value 4: Mirrored vertically. The image is flipped top-to-bottom. Row 0 is at the visual bottom, column 0 is at the visual left. To display correctly, flip vertically. This is equivalent to a horizontal mirror plus 180-degree rotation.
Value 5: Mirrored horizontally, then rotated 270 degrees clockwise. This is a transposition — rows and columns are swapped, with a horizontal mirror. To display correctly, flip horizontally and then rotate 90 degrees clockwise.
Value 6: Rotated 90 degrees clockwise. This is the most common non-standard orientation — it represents a portrait photo taken with the phone held with its top to the right. The pixel data is in landscape arrangement, and the viewer must rotate it 90 degrees clockwise. When software ignores this tag, the photo appears rotated 90 degrees counterclockwise (the person's head points to the left instead of up).
Value 7: Mirrored horizontally, then rotated 90 degrees clockwise. Another combined mirror-and-rotation transformation. Rare in practice.
Value 8: Rotated 270 degrees clockwise (or 90 degrees counterclockwise). This represents a portrait photo taken with the phone held with its top to the left. When software ignores this tag, the photo appears rotated 90 degrees clockwise (the person's head points to the right).
Values 6 and 8 are by far the most common non-standard orientations because they correspond to the two ways people hold their phones in portrait mode. Values 2, 4, 5, and 7 involve mirroring, which does not occur naturally during normal photography — they result from manual editing, front-facing camera captures (which some phones store as mirrored), or metadata corruption.
Why the Problem Persists
You might expect that in 2026, every piece of software would read the EXIF orientation tag and apply the rotation automatically. The reality is more complicated.
Web browsers have fixed this on the display side. Since around 2020, all major browsers apply EXIF orientation when displaying images in HTML img tags. CSS also defaults to respecting EXIF orientation through the image-orientation: from-image property, which is now the default in all browsers. If you display a JPEG with EXIF orientation 6 in a browser, it appears correctly rotated.
The Canvas API, however, does not automatically apply EXIF orientation. When you draw an image onto a canvas using drawImage, you get the raw pixel data in its stored orientation — the EXIF tag is ignored. This means any browser-based image processing tool that uses Canvas must manually read and apply the EXIF orientation before processing, or the output will be rotated incorrectly. This is a common source of bugs in web-based image editors.
Desktop applications vary widely. Photoshop, Lightroom, and most professional photo editors read EXIF and apply orientation automatically. Windows Photo Viewer has historically had inconsistent behavior — sometimes respecting the tag, sometimes not. Windows Explorer's thumbnail generation has its own bugs. Many bulk image processing tools, file transfer utilities, and content management systems strip or ignore EXIF data, causing orientation problems downstream.
Email clients and messaging apps add another layer of inconsistency. Some strip EXIF on send (which may fix or break orientation depending on whether the pixel data was already rotated). Some re-encode the image, baking the rotation in. Some pass the JPEG through unchanged, relying on the recipient's software to apply the tag.
The fundamental problem is that EXIF orientation creates a split between the stored pixel data and the intended display. Any tool in the chain that fails to bridge this gap produces a rotated image. The only permanent fix is to eliminate the gap by rotating the actual pixel data and setting the EXIF orientation tag to 1 (or removing it entirely).
Baking the Rotation into Pixel Data
The most reliable way to fix EXIF orientation problems is to transform the actual pixel data to match the intended display orientation and then set the EXIF orientation tag to value 1 (normal) or strip EXIF entirely. After this operation, the pixel data's row-0 is the visual top and column-0 is the visual left — no rotation needed, no tag to read, no ambiguity.
This is what our image rotate and flip tool does when you apply a rotation correction. The Canvas API is used to draw the image with the correct transformation (translate and rotate the canvas context before drawing), and the exported result contains pixel data in the correct orientation. Since Canvas export does not write EXIF data, the output PNG or JPEG has no orientation tag — which is fine because the pixels are already in the correct order.
Most professional photo management software offers a "lossless rotation" option for JPEGs that rotates the pixel data without re-encoding — it rearranges the DCT coefficient blocks in the JPEG file rather than decoding and re-encoding the image. This avoids the generation loss that comes with re-encoding but is limited to 90-degree rotation increments and only works when the image dimensions are multiples of the JPEG block size (8 or 16 pixels depending on chroma subsampling). In a browser, this level of file manipulation is not practical — Canvas-based rotation always involves decoding and re-encoding, which introduces one round of re-compression for JPEG output. The quality loss from a single high-quality re-encoding (quality 92 or above) is negligible for practical purposes.
Rotation Without EXIF: Manual Correction
Sometimes an image arrives without EXIF data but is still rotated — perhaps the EXIF was stripped during transfer, or the image was scanned from a physical document that was placed sideways. In these cases, manual rotation is the only option.
The standard rotation operations are 90 degrees clockwise (portrait photo with head to the left needs this), 90 degrees counterclockwise (portrait photo with head to the right needs this), 180 degrees (upside down), horizontal flip (mirror), and vertical flip. These can be combined — a horizontal flip followed by 90 degrees clockwise produces the same result as a vertical flip followed by 90 degrees counterclockwise.
Our image rotate and flip tool provides all of these operations with instant preview, so you can visually confirm the correction before downloading. The tool is also useful for deliberately rotating images for creative purposes — creating angled compositions, flipping product photos for mirrored layouts, or rotating scanned documents to the correct reading orientation.
How Canvas Rotation Works
Rotation in the Canvas API works by transforming the canvas's coordinate system before drawing. To rotate an image 90 degrees clockwise, you create a canvas with swapped dimensions (the canvas width equals the image height, and the canvas height equals the image width), translate the canvas origin to the appropriate corner, rotate the context by 90 degrees (pi/2 radians), and then draw the image at the (now-rotated) origin.
For 180-degree rotation, the canvas dimensions stay the same. You translate to the bottom-right corner and rotate by 180 degrees (pi radians). For horizontal and vertical flips, you use ctx.scale(-1, 1) or ctx.scale(1, -1) respectively, with appropriate translations to keep the image within the canvas bounds.
These transformations operate on the canvas's drawing context, not on the pixel data directly. The browser's rendering engine handles the actual pixel resampling during the drawImage call. For 90-degree increments, the resampling is exact — pixels are simply rearranged without any interpolation. For arbitrary rotation angles (which our tool does not offer, since arbitrary rotation requires cropping or padding the corners), interpolation would introduce slight softening.
EXIF Orientation in Different File Formats
The orientation problem is primarily a JPEG issue because JPEG is the default format for photographs from cameras and phones, and JPEG supports EXIF. However, the situation varies by format.
JPEG fully supports EXIF, including the orientation tag. This is where the vast majority of orientation problems occur.
PNG does not support EXIF in the standard specification. PNG has its own metadata mechanisms (tEXt and iTXt chunks), but they do not include an orientation concept. When you convert a rotated JPEG to PNG, the EXIF is typically stripped. If the conversion tool does not apply the rotation during conversion, the PNG will contain the raw (unrotated) pixel data with no orientation tag to correct it — the photo is permanently sideways. Good conversion tools apply the EXIF rotation before saving to PNG. Our image format converter handles this correctly by processing the image through Canvas, which renders the image as displayed (with the browser's automatic EXIF correction applied) before exporting to the target format.
WebP supports EXIF metadata, including the orientation tag. The orientation behavior in WebP mirrors that of JPEG.
HEIF/HEIC (the format used by iPhones since iOS 11) supports EXIF and handles orientation similarly to JPEG. When you AirDrop or share a HEIC image that gets converted to JPEG, the conversion may or may not bake the rotation in, depending on the conversion tool.
Preventing Orientation Problems
The most effective prevention strategy is to bake the rotation into pixel data as early as possible in your workflow. When you import photos from a camera or phone, use an import tool that applies EXIF orientation during import. When you receive images from others, run them through a rotation correction step before using them in any pipeline.
For web projects, the browser's automatic EXIF handling for img tags means display is usually fine. The risk is in processing — if you use Canvas to resize, crop, compress, or convert images, you need to handle orientation explicitly. Drawing an image onto a canvas and using the canvas output as your working copy effectively bakes the rotation in, since the browser applies EXIF correction when rendering the image element that you draw from.
Our complete image processing toolkit handles this transparently. Whether you use the image resizer, the image cropper, or the image rotate and flip tool, the browser renders the image correctly before Canvas processing begins, and the output always has the correct orientation baked into the pixel data.
The Bottom Line
EXIF orientation is a metadata-based rotation system designed to avoid the computational cost of physically rotating pixel data in-camera. It works perfectly when every tool in the chain reads and respects the tag, and it fails visibly when any tool ignores it. The permanent fix is to bake the rotation into the actual pixel data and remove the dependency on metadata interpretation. Our image rotate and flip tool does exactly this — correcting orientation visually in your browser and exporting pixel data that displays correctly everywhere, regardless of whether the viewing software supports EXIF.
References
Sirv — EXIF Orientation Values — Visual reference showing all eight EXIF orientation values with clear diagrams and display examples.
Dave Perrett — EXIF Orientation Handling Is a Ghetto — The seminal blog post documenting the inconsistency of EXIF orientation handling across software, with the widely-referenced F-letter orientation diagram.
MDN — CSS image-orientation — Documentation for the CSS property that controls how browsers handle EXIF orientation in rendered images.
Can I Use — CSS image-orientation: from-image — Browser support table for automatic EXIF orientation correction in CSS.
JEITA — Exif Standard Version 3.0 — The official EXIF specification maintained by the Camera and Imaging Products Association.