Return to Digital Photography Articles
JPEG Rotation and EXIF Orientation
Digital Cameras with orientation sensors allow auto-rotation of portrait images. Unfortunately, support for this feature is not widespread or consistently applied.
Digital Cameras with Orientation Sensors
Many newer digital cameras (both dSLR and Point & Shoot digicams) have a built-in orientation sensor. Virtually all Canon and Nikon digital cameras have an orientation sensor. The output of this sensor is used to set the EXIF orientation flag in the image file's metatdata to reflect the positioning of the camera with respect to the ground. Canon calls their sensor the "Intelligent Orientation" sensor. It is presumably a 2-axis tilt sensor, allowing 4 possible orientations to be detected (shown in the left side of the diagram below).
|EXIF Orientation Flag Values|
Note that one would only expect the four orientation settings shown on the left to be possible with a digital camera. The other four settings would imply that the resulting image was flipped horizontally before recording. Unless the camera were to encode the image right-to-left or know that you were taking a photo in a mirror, I don't see how these values will ever be used.
For the following discussion, it may be helpful to understand the concepts behind lossless rotation.
The values 1-8 represent the following descriptions (as shown by utilities that support EXIF field decode):
|EXIF Orientation Value||Row #0 is:||Column #0 is:|
NOTE: Values with "*" are uncommon since they represent "flipped" orientations.
Auto-rotation in Digital Cameras
While your digital camera may include an option to "auto-rotate images" due to the camera's orientation, this is almost always just a "virtual rotation". A flag is set to indicate to the viewing software / LCD preview which way to rotate the image before display, rather than rotating the image content itself.
As lossless image rotation is a fairly compute-intensive operation, digital cameras are not likely to include true lossless rotation after capturing the photo. The CCD/CMOS sensor hardware is designed to stream raw data in a particular direction (e.g. rows then columns), and so it may be hard to incorporate true auto-rotation in-camera without a performance impact to continuous shooting (frames per second).
Software Support for Orientation
While there are countless software programs available today that display JPEG images, only a subset of them actually interpret the EXIF Orientation flag. Just like color management, many programs simply display the JPEG image as it is stored, and completely ignore any extra details stored in the file's metadata. The most important of these additional details is the Orientation flag, stored in the JPEG APP1 marker under EXIF IFD0.
|Windows Photo Viewer (Windows 7)||No|
|Windows Picture and Fax Viewer (Windows XP)||No|
|IrfanView||Yes (need to enable)|
In IrfanView, auto-rotation is not enabled by default. To ensure that images are auto-rotated, you will find the option located under Options->Properties in the JPG/PCD/GIF tab.
Windows Picture and Fax Viewer
Surprisingly, the Windows Picture and Fax Viewer (built into Windows XP) and Windows Photo Viewer (built into Windows 7) do not support the EXIF orientation flag. This is surprising, as the makers have obviously thought enough to support lossless rotation functions. So, what you will see shown by the viewer is the real image data (assuming landscape orientation), without respecting any indication from the camera as to the real orientation of the image.
Beware of Rotating Photos in Windows Picture / Photo Viewer!
Another surprising detail is that if you decide to perform lossless image rotation (by using the Rotate Clockwise or Rotate CounterClockwise buttons), the EXIF Orientation flag is removed! As the flag is removed/reset, if you do a rotation followed by its reverse rotation on a portrait photo (eg. rotate clockwise, then rotate counter-clockwise), the resulting orientation observed by other viewers such as Photoshop will be wrong!
In fact, when you use the rotate functions of Windows Picutre Viewer, most of the image metadata (camera information, shot details, makernotes, etc.) are deleted. Therefore, I strongly recommend against using this program to rotate any of your digital photos.
I have also noticed that some images which were rotated that don't conform to 16x16 pixel multiples, the quantization tables don't appear to be rotated properly.
Because many new digital photographers may not be aware of this, Nikon even went so far as to issue a press release to warn of the potential dangers.
- NOTE: The damage is done as soon as you press one of the rotate buttons . The disk icon is just for copying the file and should not be thought of as a Save button!
The following table details some of the metadata corrupted / modified by Windows Picture and Fax Viewer:
|MakerNotes: Nearly all fields zeroed
out except: SerialNumber, ImageNumber
Note that, in general, most image editors (such as Photoshop, Lightroom and many others) do not rotate images losslessly. This is made obvious by the fact that the Save function provides compression quality options (eg. 1-12, High, Low, etc.) and is therefore applying [lossy] JPEG recompression to your image content.
There are several tools that allow the image content to be rotated losslessly in software, based on the information stored in the EXIF orientation flag. By far the best time to perform this is during image import (e.g. from memory card). Most import applications (such as DownloaderPro) can do this during the copy operation (from memory card to hard drive). Doing so ensure that all programs can see the image properly rotated, without having to rely on the EXIF Orientation flag. This means that even programs such as Microsoft's Windows Picture and Fax Viewer will also show correct orientation for portrait / vertical images.
Most programs will rotate the image content and then update the Orientation flag to reflect the new orientation (usually a value of 1), while still leaving other metadata intact.