Android Bitmap Rotate GetExifOrientation(String filepath)

Here you can find the source of GetExifOrientation(String filepath)

Description

Get Exif Orientation

Declaration

public synchronized static int GetExifOrientation(String filepath) 

Method Source Code

//package com.java2s;

import java.io.IOException;

import android.media.ExifInterface;
import android.util.Log;

public class Main {
    private static final String TAG = "CAMERA::Activity";

    public synchronized static int GetExifOrientation(String filepath) {
        int degree = 0;
        ExifInterface exif = null;/*ww  w . ja  v a  2s.  c  o  m*/

        try {
            exif = new ExifInterface(filepath);
        } catch (IOException e) {
            Log.e(TAG, "cannot read exif");
            e.printStackTrace();
        }

        if (exif != null) {
            int orientation = exif.getAttributeInt(
                    ExifInterface.TAG_ORIENTATION, -1);

            if (orientation != -1) {
                // We only recognize a subset of orientation tag values.
                switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    degree = 90;
                    break;

                case ExifInterface.ORIENTATION_ROTATE_180:
                    degree = 180;
                    break;

                case ExifInterface.ORIENTATION_ROTATE_270:
                    degree = 270;
                    break;
                }
            }
        }

        return degree;
    }
}

Related

  1. rotateBitmap(Bitmap source, int rotation, boolean recycle)
  2. rotatePic(Bitmap bitmap, int degree)
  3. rotation(Bitmap source, int degrees)
  4. GetRotatedBitmap(Bitmap bitmap, int degrees)
  5. computePictureRotation()
  6. reflectionFromBitmap(Bitmap originalBitmap, boolean isFuzzy)
  7. rotate(Bitmap bitmap, int angle)
  8. rotate(Bitmap bitmap, int degrees)
  9. rotateBitmap(Bitmap bitmap, float degrees)