Detect if images was taken in portrait mode

HimeAnator

Member
Licensed User
Longtime User
I have an ImageView that displays a horizontal image of the users choice. However if the user uses an images that was taken in portrait mode then the image is stretched out and sometimes causes the app the stop responding. So how would I detect if the image was taken vertically so I can give a message stating that image is not usable or rotate the image so it will at least display sideways and still be proportionate? I have been looking at JpegUtils but I'm not seeing anything there to detect orientation just the ORIENTATION_ROTATE_90 which will help if once I figure out if it's portrait or not.. Thanks for any help!
 

grant1842

Active Member
Licensed User
Longtime User
Get the dimensions of the image. If the height is greater than the width then it's a portrait picture.
 
Upvote 0
Top