0

when uploading this image to the server. it is rotated with 90 degree. here is a link for the image :

https://drive.google.com/file/d/0Bw8vnOWKrLfgWElsRW81SmxXeDA/view?usp=sharing

here is the code to check orientation. but it doesn't detect roation:

 /**
     * get image matrix rotation by uri
     */
    private static Matrix matrixUriImgRotation(Uri uri) {
        Log.i("imageRotatin", "image rotation called");

        ExifInterface exif = null;
        try {
            exif = new ExifInterface(uri.getPath());
        } catch (Exception e) {
            Log.i("imageRotatin", "exception:" + e.getMessage());
        }

        //get image rotation
        int exifRotation = 0;
        if (exif != null) {
            exifRotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
            Log.i("imageRotatin", "exif not null");
        }

        //convert exif rotation to degrees
        int rotationInDegrees = 0;
        if (exifRotation == ExifInterface.ORIENTATION_ROTATE_90) {
            rotationInDegrees = 90;
        } else if (exifRotation == ExifInterface.ORIENTATION_ROTATE_180) {
            rotationInDegrees = 180;
        } else if (exifRotation == ExifInterface.ORIENTATION_ROTATE_270) {
            rotationInDegrees = 270;
        }

        //build matrix
        Matrix matrix = new Matrix();
        if (exifRotation != 0) {
            Log.i("imageRotatin", "rotationInDegree:" + rotationInDegrees);
            matrix.preRotate(rotationInDegrees);
        }

        return matrix;

    }

note: other images is uploaded without problem.

david
  • 3,310
  • 7
  • 36
  • 59
  • http://stackoverflow.com/questions/20634252/image-from-gallery-rotates-automatically-android – IntelliJ Amiya Oct 05 '15 at 11:51
  • 1
    @IntelliJAmiya thank you for your comment. finally i figured out what the problem . i should pass realPath instead of uri.getPath() – david Oct 05 '15 at 13:03

0 Answers0