Exif 数据 TAG_ORIENTATION 始终为 0
我需要知道图库中图像的方向(由相机拍摄)。我最初的方法是使用适用于我的 Droid 1 的 MediaStore.Images.Media.ORIENTATION。在 HTC Thunderbolt 上进行测试时,该手机仅将 0 保存到该字段。
然后我开始读取 exif 数据:
ExifInterface exifReader = new ExifInterface(mFilePath);
exifReader.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
这也会为每个图像返回 0。有人知道如何在 Android 上正确获取照片拍摄方向吗?
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 my Droid 1. While testing on the HTC Thunderbolt that phone only saves 0 to that field.
I then moved to reading the exif data:
ExifInterface exifReader = new ExifInterface(mFilePath);
exifReader.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
This also returns 0 for every image. Anyone have ideas on how to properly get the orientation of a photo take on android?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我在活动中使用 onActivityResult() 的代码。返回的意图是选择 image/* 类型的图像。对我来说效果很好!
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!
我的解决方案:
从 exif 数据中删除任何方向检查。我找不到一个准确的例子。
使用标准
String[]orientationColumn = {MediaStore.Images.Media.ORIENTATION};
获取方向。如果这是
0
使用解码流...
否则就是风景
My solution:
Remove any checking for orientation from exif data. I could not find one instance where it was accurate.
Use the standard
String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION};
to get an orientation.If this is
0
usedecodeStream...
else it is landscape
这是我发现的一个与另一个 android bug 相关的错误。我发现这里发布了一个合理的解决方案 https://stackoverflow.com/ a/8864367/137404
This is a bug i found that was related to another android bug.. I found a reasonable solution posted here https://stackoverflow.com/a/8864367/137404