Example usage for android.media ExifInterface TAG_ORIENTATION

List of usage examples for android.media ExifInterface TAG_ORIENTATION

Introduction

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

Prototype

String TAG_ORIENTATION

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

Click Source Link

Document

Type is int.

Usage

From source file:Main.java

private static int getExifOrientation(String src) throws Exception {
    ExifInterface exifInterface = new ExifInterface(src);
    return exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
}

From source file:Main.java

public static int getImageOrientation(String uri) throws IOException {
    ExifInterface exif = new ExifInterface(uri);
    int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
    return orientation;
}

From source file:Main.java

public static int readPictureDegree(String path) {
    int degree = 0;
    try {//from   www.  ja v  a  2 s .  com
        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 getOrientationFromExif(String imagePath) {
    int orientation = 0;
    try {//from  w w w .j a v  a 2 s  .  co m
        ExifInterface exif = new ExifInterface(imagePath);
        int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);

        switch (exifOrientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
            orientation = 270;

            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            orientation = 180;

            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            orientation = 90;

            break;

        case ExifInterface.ORIENTATION_NORMAL:
            orientation = 0;

            break;
        default:
            break;
        }
    } catch (Exception e) {

    }

    return orientation;
}

From source file:Main.java

public static int getImageOrientation(String uri) {
    if (!new File(uri).exists()) {
        return 0;
    }// w w w  .j  a v  a  2 s.  com
    try {
        ExifInterface exif = new ExifInterface(uri);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        return orientation;
    } catch (Exception e) {
    }
    return 0;
}

From source file:Main.java

public static int getFileExifDegree(String path) {
    try {//w w  w  .  j  ava 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:
            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

public static int getExifRotation(String imgPath) {
    try {/*from  w ww .  j av a 2  s  .  c o  m*/
        ExifInterface exif = new ExifInterface(imgPath);
        String rotationAmount = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
        if (!TextUtils.isEmpty(rotationAmount)) {
            int rotationParam = Integer.parseInt(rotationAmount);
            switch (rotationParam) {
            case ExifInterface.ORIENTATION_NORMAL:
                return 0;
            case ExifInterface.ORIENTATION_ROTATE_90:
                return 90;
            case ExifInterface.ORIENTATION_ROTATE_180:
                return 180;
            case ExifInterface.ORIENTATION_ROTATE_270:
                return 270;
            default:
                return 0;
            }
        } else {
            return 0;
        }
    } catch (Exception ex) {
        return 0;
    }
}

From source file:Main.java

private static int getExifOrientation(String filePath) {
    ExifInterface exif;/*from w w  w .  ja  v a 2  s . com*/
    int orientation = 0;
    try {
        exif = new ExifInterface(filePath);
        orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return orientation;
}

From source file:Main.java

public static int getRotationFromExif(Context context, String bitmapPath) {
    try {/*  w  w w  . ja  va2 s .  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 getExifOrientation(String filePath) {
    int degree = 0;
    try {/*from w w w  .ja  va 2  s . co 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;
}