If you are processing photos using the Camera API, then you can check the sensors the moment the user takes the photo (clicks the button).
Using this information, you can determine the orientation of the device at the moment the photo was taken, and then take a few turns.
source share