Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import android.media.ExifInterface;

public class Main {

    private static int getExifOrientation(String filePath) {
        int degree = 0;
        try {
            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;
    }
}