Example usage for android.media ExifInterface ORIENTATION_ROTATE_90

List of usage examples for android.media ExifInterface ORIENTATION_ROTATE_90

Introduction

In this page you can find the example usage for android.media ExifInterface ORIENTATION_ROTATE_90.

Prototype

int ORIENTATION_ROTATE_90

To view the source code for android.media ExifInterface ORIENTATION_ROTATE_90.

Click Source Link

Usage

From source file:Main.java

public static int readPictureDegree(String path) {
    int degree = 0;
    try {/*from  w w w.  j  av a2s.  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 (Exception e) {
        e.printStackTrace();
    }
    return degree;
}

From source file:Main.java

public static int getFileExifDegree(String path) {
    try {/*from  ww  w.j  a v  a 2 s . co m*/
        ExifInterface exifInterface = new ExifInterface(path);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            return 90;
        case ExifInterface.ORIENTATION_ROTATE_180:
            return 180;
        case ExifInterface.ORIENTATION_ROTATE_270:
            return 270;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

private static int getExifOrientation(String filePath) {
    int degree = 0;
    try {//from ww w.j a va  2 s . c  o m
        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

/**
 * Get the # of degrees an image must be rotated to match the given exif orientation.
 *
 * @param exifOrientation The exif orientation [1-8]
 * @return the number of degrees to rotate
 *///from www  .  j  ava 2s  .com
public static int getExifOrientationDegrees(int exifOrientation) {
    final int degreesToRotate;
    switch (exifOrientation) {
    case ExifInterface.ORIENTATION_TRANSPOSE:
    case ExifInterface.ORIENTATION_ROTATE_90:
        degreesToRotate = 90;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
    case ExifInterface.ORIENTATION_FLIP_VERTICAL:
        degreesToRotate = 180;
        break;
    case ExifInterface.ORIENTATION_TRANSVERSE:
    case ExifInterface.ORIENTATION_ROTATE_270:
        degreesToRotate = 270;
        break;
    default:
        degreesToRotate = 0;

    }
    return degreesToRotate;
}

From source file:Main.java

/**
 * Get the # of degrees an image must be rotated to match the given exif orientation.
 *
 * @param exifOrientation The exif orientation [1-8]
 * @return the number of degrees to rotate
 *//*from   w  w w . j a  v  a  2  s.c  o m*/
public static int getExifOrientationDegrees(int exifOrientation) {
    final int degreesToRotate;
    switch (exifOrientation) {
    case ExifInterface.ORIENTATION_TRANSPOSE:
    case ExifInterface.ORIENTATION_ROTATE_90:
        degreesToRotate = 90;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
    case ExifInterface.ORIENTATION_FLIP_VERTICAL:
        degreesToRotate = 180;
        break;
    case ExifInterface.ORIENTATION_TRANSVERSE:
    case ExifInterface.ORIENTATION_ROTATE_270:
        degreesToRotate = 270;
        break;
    default:
        degreesToRotate = 0;
        break;
    }
    return degreesToRotate;
}

From source file:Main.java

public static int getRotationFromExif(Context context, String bitmapPath) {
    try {//from   w w  w. ja  v a 2s  .  co  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 readPictureDegree(String path) {
    int degree = 0;
    try {//from  ww  w.j  a v a2  s  .  c om
        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 {/* ww  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   ww w.  ja v a2s. 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 getRotation(String jpegFilePath) {
    int degrees = 0;
    try {/*www  .  j ava2 s .c o  m*/
        ExifInterface exifInterface = new ExifInterface(jpegFilePath);
        int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            degrees = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degrees = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degrees = 270;
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return degrees;
}