Beispiel #1
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;
 }
 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;
 }