CleanUp/ExifOrientation

The Exif specification defines an Orientation Tag to indicate the orientation of the camera relative to the captured scene. This can be used by the camera either to indicate the orientation automatically by an orientation sensor, or to allow the user to indicate the orientation manually by a menu switch, without actually transforming the image data itself.

Here is an explanation given by TsuruZoh? Tachibanaya in his description of the Exif file format:

The orientation of the camera relative to the scene, when the image was captured. The relation of the '0th row' and '0th column' to visual position is shown as below.

Value0th Row 0th Column
1 top left side
2 top right side
3 bottom right side
4 bottom left side
5 left side top
6 right side top
7 right side bottom
8 left side bottom

Read this table as follows (thanks to Peter Nielsen for clarifying this - see also below): Entry #6 in the table says that the 0th row in the stored image is the right side of the captured scene, and the 0th column in the stored image is the top side of the captured scene.

Here is another description given by Adam M. Costello:

For convenience, here is what the letter F would look like if it were tagged correctly and displayed by a program that ignores the orientation tag (thus showing the stored image):

   1        2       3      4         5            6           7          8

888888  888888      88  88      8888888888  88                  88  8888888888
88          88      88  88      88  88      88  88          88  88      88  88
8888      8888    8888  8888    88          8888888888  8888888888          88
88          88      88  88
88          88  888888  888888