Android ExifInterface Get getExifDegree(String filepath)

Here you can find the source of getExifDegree(String filepath)

Description

get Exif Degree

Declaration

public static int getExifDegree(String filepath) 

Method Source Code

//package com.java2s;

import java.io.IOException;

import android.media.ExifInterface;

public class Main {
    public static int getExifDegree(String filepath) {
        int degree = 0;
        ExifInterface exif;/*from  w  w  w.  j ava  2s.  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;
    }
}

Related

  1. getExifOrientation(String filepath)