Exif data TAG_ORIENTATION always 0

后端 未结 3 1806
别那么骄傲
别那么骄傲 2020-12-05 07:03

I need to know the orientation of an image from the gallery (taken by the camera). My initial approach was to use MediaStore.Images.Media.ORIENTATION which was working for m

3条回答
  •  执笔经年
    2020-12-05 07:39

    Here is the code I used onActivityResult() in my activity. The intent returned was for picking an image of the type image/*. Works well for me!

    Uri imageUri = intent.getData();
    String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION};
    Cursor cur = managedQuery(imageUri, orientationColumn, null, null, null);
    int orientation = -1;
    if (cur != null && cur.moveToFirst()) {
        orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0]));
    }  
    Matrix matrix = new Matrix();
    matrix.postRotate(orientation);
    

提交回复
热议问题