Exemplo n.º 1
0
 // Returns the degrees in clockwise. Values are 0, 90, 180, or 270.
 public static int getOrientation(ExifInterface exif) {
   Integer val = exif.getTagIntValue(ExifInterface.TAG_ORIENTATION);
   if (val == null) {
     return 0;
   } else {
     return ExifInterface.getRotationForOrientationValue(val.shortValue());
   }
 }
Exemplo n.º 2
0
 // group index
 public static int getGroupIndex(ExifInterface exif) {
   Integer val = exif.getTagIntValue(ExifInterface.TAG_GROUP_INDEX);
   if (val == null) {
     return 0;
   } else {
     Log.i(TAG, "group index = " + val.intValue());
     return val.intValue();
   }
 }
 private static int getRotationFromExifHelper(
     String path, Resources res, int resId, Context context, Uri uri) {
   ExifInterface ei = new ExifInterface();
   try {
     if (path != null) {
       ei.readExif(path);
     } else if (uri != null) {
       InputStream is = context.getContentResolver().openInputStream(uri);
       BufferedInputStream bis = new BufferedInputStream(is);
       ei.readExif(bis);
     } else {
       InputStream is = res.openRawResource(resId);
       BufferedInputStream bis = new BufferedInputStream(is);
       ei.readExif(bis);
     }
     Integer ori = ei.getTagIntValue(ExifInterface.TAG_ORIENTATION);
     if (ori != null) {
       return ExifInterface.getRotationForOrientationValue(ori.shortValue());
     }
   } catch (IOException e) {
     Log.w(LOGTAG, "Getting exif data failed", e);
   }
   return 0;
 }