Today I had (again) the problem that not all programs support EXIF orientation in JPG photos and don't rotate them automatically. Although Digikam is supposed to reset rotation automatically when downloading the images, not all are going through that process and are copied directly from other sources.

With the help of exiv2 and convert I was able to write a small php script that takes a number of files as parameters and rotates them according to their EXIF orientation settings. After rotation is done, exif orientation is reset to 1.

You can find the source at svn.cweiske.de.

While looking for more EXIF information I found some interesting articles about hidden data in images through exif:

Update: 2007-11-10

On Gentoo, media-libs/jpeg ships a tool called exifautotran ... which does exactly what I want.

Update 2008-06-08

exifautotran does not do exactly what I want, which is why I continue to use my own script. You can now install it using PEAR:

$ pear channel-discover zustellzentrum.cweiske.de
$ pear install zz/exifrotator-beta
$ exif-rotator.php /path/to/your/images/*.jpg

I'm looking for a new job. If you can recommend a company in Leipzig/Germany that's looking for a PHP developer, please drop me a mail.

Written by Christian Weiske.

Comments? Please send an e-mail.