Reference
The eight EXIF orientation values, one by one
The EXIF Orientation field holds a single number between 1 and 8. Two of those values are what almost everyone means by the field — upright, and a quarter turn — and the remaining six are the ones nobody expects, four of them because what they describe is a reflection rather than a rotation. Every one is listed below with what it means about the samples sitting in the file, rather than about what you see.
Read each diagram as the raw contents of the file: the shape a program would show you if it ignored the tag entirely. The sentence beside it is what a program that reads the tag does before drawing.
The table
- 1 — upright
- The stored pixels are shown exactly as they sit in the file. Nothing is corrected.
- 2 — mirrored left to rightincludes a mirror
- The stored pixels are flipped across the vertical axis before display.
- 3 — rotated 180°
- The stored pixels are turned half a revolution before display.
- 4 — mirrored top to bottomincludes a mirror
- The stored pixels are flipped across the horizontal axis before display.
- 5 — mirrored, then rotated 90° anticlockwiseincludes a mirror
- The stored pixels are flipped left to right and then turned a quarter anticlockwise.
- 6 — rotated 90° clockwise
- The stored pixels are turned a quarter clockwise before display. This is what a phone held upright writes.
- 7 — mirrored, then rotated 90° clockwiseincludes a mirror
- The stored pixels are flipped left to right and then turned a quarter clockwise.
- 8 — rotated 90° anticlockwise
- The stored pixels are turned a quarter anticlockwise before display.
Which of them you will actually meet
In practice, 1, 3, 6 and 8 account for very nearly everything. They are the four values a camera writes when the body is held at each of the four right angles, and they are the four that contain no reflection. If you inspect a thousand photographs from phones, you should expect to see those four and nothing else.
The four mirrored values — 2, 4, 5 and 7 — turn up in a narrower set of places: film scanned emulsion-side up, some front-facing camera pipelines that record the preview rather than the corrected capture, a few document scanners, and files that have passed through software that wrote the field by hand and got it wrong. They are legal, they are rare, and a tool that quietly treats value 7 as though it were value 6 will produce a mirror-image of somebody’s document.
Why the field is easy to get wrong
The specification describes each value by where the first row and the first column of the stored array end up in the displayed picture — for value 6, “the 0th row is the visual right-hand side, the 0th column is the visual top”. That is precise and it is almost impossible to hold in your head, which is why implementations disagree about the direction of the quarter turn more often than they disagree about anything else in EXIF. The safest test of any implementation is an asymmetric glyph like the one above: a square with a dot in the corner will not reveal a transposition, and a letter will.
A second trap is that the field describes the main image only. The embedded preview thumbnail in the same metadata block has its own orientation, and correcting one without the other is why a repaired file can still preview sideways in a file manager.
To read the value out of a file of your own, open it on the orientation page. For the reason the field exists at all, see why a photo turns sideways when you upload it.