Beispiel #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());
   }
 }
Beispiel #2
0
 public static ExifInterface getExif(byte[] jpegData) {
   ExifInterface exif = new ExifInterface();
   try {
     exif.readExif(jpegData);
   } catch (IOException e) {
     Log.w(TAG, "Failed to read EXIF data", e);
   }
   return exif;
 }
Beispiel #3
0
 // focus value low
 public static long getFocusValueLow(ExifInterface exif) {
   Long val = exif.getTagLongValue(ExifInterface.TAG_FOCUS_VALUE_HIGH);
   if (val == null) {
     return 0l;
   } else {
     Log.i(TAG, "focus value low = " + val.longValue());
     return val.longValue();
   }
 }
Beispiel #4
0
 // group id
 public static long getGroupId(ExifInterface exif) {
   Long val = exif.getTagLongValue(ExifInterface.TAG_GROUP_ID);
   if (val == null) {
     return 0l;
   } else {
     Log.i(TAG, "group id = " + val.longValue());
     return val.longValue();
   }
 }
Beispiel #5
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;
 }