List of usage examples for android.media ExifInterface ExifInterface
public ExifInterface(InputStream inputStream) throws IOException
From source file:Main.java
public static int getDegress(String path) { int degree = 0; try {/* w ww . j a 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
private static Bitmap turnPic(final String path, Bitmap bitmap) { ExifInterface exif;//from w ww .j a v a2 s .c o m final int ninetyDegrees = 90; int rotationAngle = 0; Matrix matrix = new Matrix(); if (path != null) { try { exif = new ExifInterface(path); int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exifOrientation) { case ExifInterface.ORIENTATION_ROTATE_90: rotationAngle = ninetyDegrees; break; case ExifInterface.ORIENTATION_ROTATE_180: rotationAngle = ninetyDegrees * 2; break; case ExifInterface.ORIENTATION_ROTATE_270: rotationAngle = ninetyDegrees * 3; break; case ExifInterface.ORIENTATION_NORMAL: default: break; } } catch (IOException e) { e.printStackTrace(); return bitmap; } if (rotationAngle != 0) { matrix.postRotate(rotationAngle); } bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } return bitmap; }
From source file:Main.java
private static ExifInterface getExif(String path) { try {/*from w w w. j a v a 2 s .c om*/ return new ExifInterface(path); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static int getOrientation(Context context, Uri photoUri, File file) { /* it's on the external media. */ Cursor cursor = context.getContentResolver().query(photoUri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); if (cursor != null && cursor.getCount() != 1) { cursor.moveToFirst();/*w w w.j av a 2 s . c o m*/ return cursor.getInt(0); } int rotate = 0; ExifInterface exif = null; try { exif = new ExifInterface(file == null ? getPath(context, photoUri) : file.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; case ExifInterface.ORIENTATION_NORMAL: rotate = 0; break; } return rotate; }
From source file:Main.java
/** * Return the rotation of the passed image file * * @param filepath/*from w w w . j ava 2 s . c o m*/ * image absolute file path * @return image orientation */ public static int getExifOrientation(final String filepath) { if (null == filepath) return 0; ExifInterface exif = null; try { exif = new ExifInterface(filepath); } catch (IOException e) { return 0; } return getExifOrientation(exif); }
From source file:Main.java
public static int getExifDegree(String filepath) { int degree = 0; ExifInterface exif;/*from w ww.j a va2 s. c o m*/ try { exif = new ExifInterface(filepath); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return 0; } if (exif != null) { int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); if (orientation != -1) { 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; } } } return degree; }
From source file:Main.java
public static int getRotateDegree(String path) { int result = 0; try {// w w w . j a v a 2 s .c om 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; }
From source file:Main.java
public static int getExifOrientation(String filepath) { int degree = 0; ExifInterface exif = null;// w w w .j a v a2s . c om try { exif = new ExifInterface(filepath); } catch (IOException ex) { ex.printStackTrace(); } if (exif != null) { int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); if (orientation != -1) { // We only recognise a subset of orientation tag values. 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; } } } return degree; }
From source file:Main.java
public static int getPictureDegree(String imagePath) { int i = 0;//from w w w . java 2 s . com try { ExifInterface localExifInterface = new ExifInterface(imagePath); int j = localExifInterface.getAttributeInt("Orientation", 1); switch (j) { case 6: i = 90; break; case 3: i = 180; break; case 8: i = 270; case 4: case 5: case 7: default: break; } } catch (IOException localIOException) { localIOException.printStackTrace(); } return i; }
From source file:Main.java
public static int getOrientation(final String imagePath) { int rotate = 0; try {//from w w w.j a v a 2 s . c o m File imageFile = new File(imagePath); ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } } catch (Exception e) { e.printStackTrace(); } return rotate; }