Turn your phone sideways and the image can follow before you think about it. This video looks inside the accelerometer that gives the phone a reading of which way is down.
From the YouTube description
An accelerometer measures tiny internal movements caused by gravity. Your phone uses those readings to work out its orientation and rotate the picture when the app and settings allow it.