While sorting out all my holiday photographs, I turned them to the right orientation using F-Spot photo manager. When I came home I imported them into Adobe bridge, sorted them all out using all sorts of labels, tags and ratings.
Everything was fine so far, until I looked at them with a bad viewer, or uploaded them to Facebook. F-Spot and Bridge happily adjusted the orientation in the EXIF meta-date, but left the actual image untouched.
Not all viewers check the EXIF data before displaying an image, so they display it in the original orientation, corresponding to orientation 1 in EXIF.
Now I was stuck with over a thousand neatly sorted and rotated photos, that I could not publish without rotating them all again with another application.
Luckily I was saved by this page: http://sylvana.net/jpegcrop/exif_orientation.html
If you run Mac and probably Linux as well, jpegtran is already installed.
Just download the C app and the Bash script, but them in the same folder and run this command to compile:
gcc -o jpegexiforient jpegexiforient.c
Now run these commands to make the files executable:
chmod +x jpegexiforient chmod +x exifautotran
I had to change exifautotran to read ./jpegexiforient in 2 places instead of just jpegexiforient. Otherwise it'd say "command not found".
Now you can run "./exifautotran file.jpg" to convert a single file, or "./exifautotran /dir/*.jpg" to convert a whole directory of jpg files.