obtain Bitmap File Orientation - Android Graphics

Android examples for Graphics:Bitmap File

Description

obtain Bitmap File Orientation

Demo Code


//package com.java2s;

import android.media.ExifInterface;

import android.text.TextUtils;

import java.io.IOException;

public class Main {
    private static int obtainFileOrientation(String fileName) {
        if (TextUtils.isEmpty(fileName)) {
            return ExifInterface.ORIENTATION_UNDEFINED;
        }//w ww .  j  a  v  a  2 s .  c o  m
        try {
            ExifInterface exifInterface = new ExifInterface(fileName);
            return exifInterface.getAttributeInt(
                    ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_NORMAL);
        } catch (IOException e) {
            return ExifInterface.ORIENTATION_UNDEFINED;
        }
    }
}

Related Tutorials