Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExifInterface returns image orientation 0

I am trying to get the orientation of an image (from gallery), but ExifInterface always returns 0. here is the code:

int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);

like image 804
Muhammad Umair Avatar asked Feb 15 '26 06:02

Muhammad Umair


1 Answers

A bit late to the party, but I hope to help other developers struggling with this.

What helped me fix the issue was using:

android.support.media.ExifInterface

instead of

android.media.ExifInterface

It seems the ExifInterface from the support library does a better job at handling the various orientations. Please pay attention to the warnings the IDE gives. My warning was hiding inside a collapsed list of imports.

like image 157
TGO Avatar answered Feb 17 '26 21:02

TGO



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!