이미지의 GPS 위치를 얻으려는 중일 때 null이/0 인 경우 다른 이미지에서 다른 exif 정보를 가져 오려고했으나 결과는 여전히 null/0모든 ExifInterface 값이 0 또는 null을 반환합니다.
입니다.첫 번째 토스트는 /storage/sdcard0/etp_images/test.jpg와 같은 이미지의 절대 경로를 표시하지만 두 번째 토스트는 0 또는 null 만 결과로 표시합니다.
이미지의 GPS 위치를 얻으려는 중일 때 null이/0 인 경우 다른 이미지에서 다른 exif 정보를 가져 오려고했으나 결과는 여전히 null/0모든 ExifInterface 값이 0 또는 null을 반환합니다.
입니다.첫 번째 토스트는 /storage/sdcard0/etp_images/test.jpg와 같은 이미지의 절대 경로를 표시하지만 두 번째 토스트는 0 또는 null 만 결과로 표시합니다.
아마도 해결책은 아니지만 전에 ExifInterface
에 문제가있었습니다. 원본 클래스 ExifInterface
에는 다른 버그가 있습니다. 이 클래스의 지원 버전을 사용해보십시오. 제 경우에는 제 문제가 해결되었습니다. 이 사용 Gradle을 컴파일 다음을 얻기 위해 다음과 같은 방법을
compile 'com.android.support:exifinterface:25.1.0'
도 썼다 :
정말 고마워요! 귀하의 방법은 실제로 작동합니다! 마지막으로 –
당신은 환영합니다 :) – Kostya
나는 xamarin android에서 일하고 있습니다. 나는 "Exif 지원 라이브러리"를 설치했지만 여전히이 링크를 사용하고 있습니다 : https://www.nuget.org/packages/Xamarin.Android.Support.Exif/25.4.0.2하지만 헛소리 나는 직면하고 있습니다. –
com.android.support:exifinterface:25.1.0
내가 같은 문제는 내가 또한 다음과 같은 의존성 내 프로젝트에 ExifInterface 지원 라이브러리를 추가했다 이미지 방향 각도 :
private int getImageAngle(Uri uri, String imagePath) {
int orientation;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
orientation = getOrientation(uri);
} else {
orientation = getOrientationLegacy(imagePath);
}
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
return 180;
case ExifInterface.ORIENTATION_ROTATE_270:
return 270;
}
return 0;
}
@TargetApi(Build.VERSION_CODES.N)
private int getOrientation(Uri uri) {
InputStream in = null;
ExifInterface exif = null;
try {
in = getContentResolver().openInputStream(uri);
exif = new ExifInterface(in);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ignored) {
}
}
}
return getExifAttributeInt(exif);
}
private int getOrientationLegacy(String imagePath) {
ExifInterface exif = null;
try {
exif = new ExifInterface(imagePath);
} catch (IOException e) {
e.printStackTrace();
}
return getExifAttributeInt(exif);
}
private int getExifAttributeInt(ExifInterface exif) {
if (exif != null) {
return exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
} else {
return ExifInterface.ORIENTATION_NORMAL;
}
}
GPS 경도가있는 자신의 이미지로 코드를 시험해보십시오. –
나는 그것을했고, 작동하지 않았다. –