Howto auto-rotate digital photos to their proper orientation
From Wikihowto
Some digital cameras can record the orientation of the camera when the photo is taken. This is recoded in the images exif data. The images can be rotated 90°, 180°, 270°, or none if the picture is OK.
This will not work on all digital cameras
[edit] Graphical
- Using ABC-View Manager to rotate images
- Using f-spot to rotate images
- Photo management software such as mono's f-spot will automatically rotate photos with the proper meta-data upon import.
- http://www.f-spot.org
[edit] Command line
The standard jpeg library comes with a two programs called jpegexiforient, and jpegtran. There is also a script dubed, exifautotran, uses these programs to reads exif data labeled Orientation, and automaticly rotate the image to the proper orientation. 90°, 180°, 270°, or none.
- Most unixes such a Linux have the jpeg lib installed but if you don't:
- Download: jpegsrc-*.tar.gz, compile and install, or install it using your favorite package manager
- Create script using the code here: exifautotran code.
- check to see if your jpeg package comes with exifautotran before you waste time making the script
- don't forget to make it executable, chmod 755 exifautotran
- Execute: exifautotran image_name
- rotates a single image
- Execute: exifautotran *
- rotates all images in a directory, if needed.
See http://jpegclub.org/exif_orientation.html for details
Note: The exifautotran script uses the command jpegexiforient to figure out the orientation stored in the exif label of a file. However, it may fail to read jpeg files storing JFIF standard 1.01 information. Reading such files can be performed manually using the exiftool utility.
For example, the following command will retrieve orientation information from a JFIF file:
exiftool -t -s -n -IFD0:Orientation -IFD1:Orientation
And to set the orientation in both IFD0 and IFD1 tags to default (no rotation), use:
exiftool -n -IFD0:Orientation=1 -IFD1:Orientation=1
