read Picture Rotation Degree - Android Graphics

Android examples for Graphics:Image Rotate

Description

read Picture Rotation Degree

Demo Code


//package com.java2s;

import java.io.IOException;

import android.media.ExifInterface;

public class Main {

    public static int readPictureDegree(String path) {
        int degree = 0;
        try {//from ww w  .  java 2  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;
    }
}

Related Tutorials