How does Image Viewer know to autorotate pictures?
Sebastian Wright
I have two files, which were once identical, but one was rotated using Windows Photo Viewer on Windows. Let's call them the raw image and the rotated image. The logical representation of this image is portrait.
The raw image has a width of 5184 and a height of 3456 (as reported by the Image tab in the properties of the file), so it is a landscape image.
The rotated image has, obviously, a width of 3456 and a height of 5184, so it is a portrait image.
Nevertheless, when I open any of these two files on Ubuntu, they are displayed in the portrait mode in Image Viewer and I can't wrap my head around why this is happening. How does Image Viewer know which is the logical way of observing this image?
EDIT: Ubuntu also seems to know where is the up in the picture, since the thumbnails are correctly represented also, against the width and height values.
3 Answers
There may be meta information embedded within the image file that gives clues as to the orientation of the image.
Ubuntu's image viewer will soft rotate them automatically depending on this meta data. Windows Photo Viewer has traditionally ignored this information.
This can lead to unexpected results. One program may obey the orientation and rotate for viewing, while others may not.
There is an Exif Orientation attribute that can have 1 of 8 values. There may be other schemes/meta data representations for image orientation. Cameras can embed this information at the time of shot.
To read this meta data I found Imagemagick useful. There are other meta data viewers available. You may be able to display these embedded attributes from within your photo/image viewing program (look for image properties).
To view with Imagemagick:
$ sudo apt-get install imagemagick
$ identify -verbose /path/to/image.file 1 There are some metadata associated with a particular image,which tells the Image Viewer in which orientation your Image should be displayed. To see more go to terminal and type
less /path/to/your/image.jpg Thank you both for your answers, while they are helpful, I found the easiest way to determine why this is happening.
Using the default Image Viewer I right-clicked on the image -> Properties -> Details tab -> Expand Image Data group > Orientation. This meta-data tells the viewer and Ubuntu how to view the picture.
This is only possible because the camera has an accelerometer that can figure which way is up and saves this as meta-data in the file. Windows Photo Viewer doesn't know how to handle this meta-data and ignores it, thus requiring rotation, which modifies the original data, for proper viewing.
0