check ExIfInof of image - Android android.graphics

Android examples for android.graphics:Image Operation

Description

check ExIfInof of image

Demo Code

import java.io.IOException;

import android.media.ExifInterface;

public class Main{


    /**/*from ww w .ja  va  2  s.c  om*/
     * This method is use for check ExIfInof of image.
     *
     * @param mediaFile
     *
     **/
    public static int checkExIfInfo(String mediaFile) {
        final ExifInterface exif;
        int rotation = 0;
        try {
            exif = new ExifInterface(mediaFile);
            final String exifOrientation = exif
                    .getAttribute(ExifInterface.TAG_ORIENTATION);
            if (exifOrientation.equals("6")) {
                rotation = 90;// Rotation angle
            } else if (exifOrientation.equals("1")) {
                rotation = 0;// Rotation angle
            } else if (exifOrientation.equals("8")) {
                rotation = 270;// Rotation angle
            } else if (exifOrientation.equals("3")) {
                rotation = 180;// Rotation angle
            } else if (exifOrientation.equals("0")) {
                rotation = 0;// Rotation angle
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return rotation;
    }

}

Related Tutorials