List of usage examples for android.media ExifInterface getAttributeInt
public int getAttributeInt(String tag, int defaultValue)
From source file:Main.java
public static Bitmap processToteImage(String image_path, Bitmap bm) { Bitmap bitmap = null;//from w w w . ja va 2s . c o m try { ExifInterface exif = new ExifInterface(image_path); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); Log.d("EXIF", "Exif: " + orientation); Matrix matrix = new Matrix(); if (orientation == 6) { matrix.postRotate(90); } else if (orientation == 3) { matrix.postRotate(180); } else if (orientation == 8) { matrix.postRotate(270); } bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true); // rotating // bitmap } catch (Exception e) { } return bitmap; }
From source file:Main.java
public static int getRotationFromExif(Context context, String bitmapPath) { try {// w w w .j a v a2 s . c o m ExifInterface ei = new ExifInterface(bitmapPath); int exifOrientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); switch (exifOrientation) { case ExifInterface.ORIENTATION_ROTATE_90: return 90; case ExifInterface.ORIENTATION_ROTATE_180: return 180; case ExifInterface.ORIENTATION_ROTATE_270: return 270; case ExifInterface.ORIENTATION_NORMAL: return 0; } } catch (Exception e) { } return -1; }
From source file:Main.java
private static int getExifOrientation(String filePath) { int degree = 0; try {//from w ww . jav a 2s. c om ExifInterface exif = new ExifInterface(filePath); int result = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); switch (result) { case ExifInterface.ORIENTATION_ROTATE_90: degree = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degree = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degree = 270; break; default: break; } } catch (IOException e) { e.printStackTrace(); } return degree; }
From source file:Main.java
private static int readPictureDegree(String path) { int degree = 0; try {/*from w w w . ja va 2 s .c o m*/ ExifInterface exifInterface = new ExifInterface(path); int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: degree = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degree = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degree = 270; break; } } catch (IOException e) { e.printStackTrace(); } return degree; }
From source file:Main.java
public static int getImageDegree(String path) { int degree = 0; try {//from w w w . j a v a 2 s . c o m ExifInterface exifInterface = new ExifInterface(path); int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: degree = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degree = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degree = 270; break; } } catch (IOException e) { e.printStackTrace(); } return degree; }
From source file:Main.java
public final static int getDegress(String path) { int degree = 0; try {//from w ww . ja v a 2s . co m ExifInterface exifInterface = new ExifInterface(path); int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: degree = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degree = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degree = 270; break; } } catch (IOException e) { e.printStackTrace(); } return degree; }
From source file:Main.java
public static int getOrientation(String path) { try {/*from w w w . j a va 2s . c o m*/ ExifInterface exif = new ExifInterface(path); return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0); } catch (IOException e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static int getRotatedDegree(String path) { int rotate = 0; try {/*from w w w. j av a2 s .c o m*/ ExifInterface exifInterface = new ExifInterface(path); int result = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); switch (result) { case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; default: break; } } catch (Exception e) { e.printStackTrace(); } return rotate; }
From source file:Main.java
/** * Extracts the EXIF rotation tag of an image file. * * @param filePath Path to the image file * @return Rotation in degrees// w w w. j a va 2 s . c om * @throws IOException */ public static int getExifRotation(String filePath) throws IOException { ExifInterface exif = new ExifInterface(filePath); int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exifOrientation) { case ExifInterface.ORIENTATION_ROTATE_90: return 90; case ExifInterface.ORIENTATION_ROTATE_180: return 180; case ExifInterface.ORIENTATION_ROTATE_270: return 270; default: return 0; } }
From source file:Main.java
public static int getRotateDegree(String path) { int result = 0; try {/* w w w . j a v a 2s .com*/ ExifInterface exif = new ExifInterface(path); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: result = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: result = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: result = 270; break; } } catch (IOException ignore) { return 0; } return result; }