Resolves a bitmap's orientation by looking at exif metadata. - Android Graphics

Android examples for Graphics:Bitmap Resource

Description

Resolves a bitmap's orientation by looking at exif metadata.

Demo Code


//package com.java2s;

import android.media.ExifInterface;

import java.io.IOException;

public class Main {
    /**//from   w ww .  j ava 2  s  .  co  m
     * Resolves a bitmap's orientation by looking at exif metadata.
     * @param bitmapAbsPath the path to the bitmap in the filesystem
     * @return the orientation attribute
     * @throws IOException on error reading the file
     */
    public static int resolveBitmapOrientation(String bitmapAbsPath)
            throws IOException {
        ExifInterface exif = null;
        exif = new ExifInterface(bitmapAbsPath);
        return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
    }
}

Related Tutorials