갤럭시탭을 이용해서 개발을 진행중인데 갤러리에 있는 이미지를 불러오면 임의로 이미지가 회전되는 현상이 발생합니다.
Exif정보를 읽어서 반대로 방향을 돌려주려고 했는데 파일을 통해서 Exif정보를 전혀 읽을 수가 없었습니다.
갤탭에 있는 카메라로 촬영한거구요.
Exif정보를 보여주는 PC용 프로그램을 통해 확인 해 보면 정보가 제대로 나오는데 안드로이드상에서는 제대로 나오지 않네요..
어디가 문제일까요;
갤럭시탭에서 해봤씁니다. 잘됩니다.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, PHOTO_PICKED);
onActivityResult 에서 아래와 같이 커서에서 orientation 값을 바로 얻어도 되구요. ExifInterface 로 조회해도 되구요.
String [] proj={MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID, MediaStore.Images.ImageColumns.ORIENTATION};
cursor = activity.managedQuery( imageUri,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int file_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
int orientation_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION);
if (cursor.moveToFirst()) {
String orientation = cursor.getString(orientation_ColumnIndex);
trace("orientation ? " + orientation);
try {
orientationOfPickedImage = Integer.parseInt(orientation);
} catch (Exception e) {
orientationOfPickedImage = 0;
}
String filepath = cursor.getString(file_ColumnIndex);
ExifInterface exif = new ExifInterface(filepath);
커서를 통해 접근해서 받아오는 코드로 하니 잘 되네요..ㅜ감사합니다
로그인 유지
갤럭시탭에서 해봤씁니다. 잘됩니다.
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, PHOTO_PICKED);
onActivityResult 에서 아래와 같이 커서에서 orientation 값을 바로 얻어도 되구요. ExifInterface 로 조회해도 되구요.
String [] proj={MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID, MediaStore.Images.ImageColumns.ORIENTATION};
cursor = activity.managedQuery( imageUri,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int file_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
int orientation_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION);
if (cursor.moveToFirst()) {
String orientation = cursor.getString(orientation_ColumnIndex);
trace("orientation ? " + orientation);
try {
orientationOfPickedImage = Integer.parseInt(orientation);
} catch (Exception e) {
orientationOfPickedImage = 0;
}
String filepath = cursor.getString(file_ColumnIndex);
ExifInterface exif = new ExifInterface(filepath);
}