I would like to rotate photos automatically, even when EXIF metadata about the image orientation is not available.
Are there any good algorithms for detecting the or
Many photographs from consumer digital cameras are of people, which could be used for orientation. Face detection is a well-studied research area. Basic face detection would give you a rectangle whose longer side should be the vertical dimension. Further, if you can detect the eyes/mouth, you should be able to pick the correct orientation of the rectangle.
Many other photographs are tourist snaps, where the sky is up and blue, and the ground is down and green.