【发布时间】:2019-11-05 15:31:30
【问题描述】:
我正在使用 Firebase 为我的 Android 应用存储图像。然后图像会出现在我的应用程序中的回收站视图中。这一切都很好,但是,某些图像出现在侧面。特别是那些用 Galaxy S7 拍摄的。
我知道我需要从图像中获取 exif 信息,但是当我尝试时出现未找到文件的错误,我该怎么办?
private int getImageOrientation(String imagePath){
int rotate = 0;
try {
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return rotate;
}
W/System.err: java.io.FileNotFoundException: /https:/firebasestorage.googleapis.com/v0/b/pickit-d193d.appspot.com/o/posts%2Ff12e73ad-9bc5-4485-90e5-927dbf8539a5.jpg?alt=media&token=9f92c0d7-0518-4721-a7b5-235c1fb3cc76 (No such file or directory)
我只需要它来返回图像旋转了多少,但它总是返回 0,因为它会抛出一个 File not found 表达式。任何帮助将不胜感激。
【问题讨论】:
标签: java android firebase picasso exif