get Picture Degree - Android Graphics

Android examples for Graphics:Image Rotate

Description

get Picture Degree

Demo Code


//package com.java2s;

import android.media.ExifInterface;
import java.io.IOException;

public class Main {

    public static int getPictureDegree(String path) {
        int degree = 0;
        try {/*from   w  w  w .  j a va  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:
                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;
    }
}

Related Tutorials