Exif 数据 TAG_ORIENTATION 始终为 0 [英] Exif data TAG_ORIENTATION always 0

查看:21
本文介绍了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 上正确获取照片的方向?

解决方案

我的解决方案:

从 exif 数据中删除任何方向检查.我找不到一个准确的实例.

使用标准 String[]orientationColumn = {MediaStore.Images.Media.ORIENTATION}; 获取方向.

如果这是 0 使用解码流...

<块引用>

if(o.outHeight > o.outWidth){//设置方向为纵向}

否则是风景

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?

解决方案

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 use decodeStream...

if(o.outHeight > o.outWidth){
  //set orientation to portrait
}

else it is landscape

这篇关于Exif 数据 TAG_ORIENTATION 始终为 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆