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

查看:1242
本文介绍了Exif数据中TAG_ORIENTATION始终为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道的图像从画廊(相机拍摄)的方向。我最初的方法是使用MediaStore.Images.Media.ORIENTATION这是工作为我的Droid 1.在测试的HTC霹雳的手机只保存0到该字段。

我然后转移到读取EXIF数据:

  ExifInterface exifReader =新ExifInterface(mFilePath);
 exifReader.getAttributeInt(ExifInterface.TAG_ORIENTATION,-1);
 

这也将返回0,每一个形象。任何人对如何正确获取照片的方向采取在Android的想法?

解决方案

我的解决办法:

删除任何检查从EXIF数据的方向。我无法找到一个实例,它是准确的。

使用标准的的String [] orientationColumn = {MediaStore.Images.Media.ORIENTATION}; 来得到一个方向

如果这是 0 使用 德codeStream ...

 如果(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天全站免登陆