Fixed bugs related to calculation of image orientation angle