Automatic rotation of images from digital cameras

Some of today’s digital camera have a gravitation sensor built in. With an option in the menu, it is possible to force these cameras to note which way was the camera when the image was taken. Usually, ‘Orientation: ‘ EXIF header is added to the JPEG image. Read on to find out how you can use this information.There is, of course, a fast and easy way to rotate these JPEG images according to this header. Two programs are needed to do it in the most painless way possible: jhead and jpegtran. jhead can be downloaded from http://www.sentex.net/~mwandel/jhead/. jpegtran is the part of most Linux distributions (package libjpeg).

Here is the magic:



[leonid@home images]$ jhead -autorot *.jpg


This will rotate all images according to the ‘Orientation: ‘ header. It will also reset the header to value ‘1’, so that if you accidentally run the jhead command on the same images again, it will not rotate them again.

Note, that if you have already rotated the images with ImageMagick’s rotate or any other tool, EXIF headers might be still present and jhead will rotate images again.

Leave a Comment