Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.media.ExifInterface;

import java.io.IOException;

public class Main {

    public static int getRotation(String jpegFilePath) {
        int degrees = 0;
        try {
            ExifInterface exifInterface = new ExifInterface(jpegFilePath);
            int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_NORMAL);
            switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                degrees = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                degrees = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                degrees = 270;
                break;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return degrees;
    }
}