read Picture Degree - Android Media

Android examples for Media:Picture

Description

read Picture 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 .  j  a va  2s .  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;
    }
}

Related Tutorials