如何确定照片的方向,而不会ExifInterface? [英] How to determine orientation of picture without ExifInterface?

查看:300
本文介绍了如何确定照片的方向,而不会ExifInterface?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将图像加载到一个位图,并需要知道抽放图片(从摄像机)的方向正确地表现出来。使用下面的code的方式工作很好(因为API等级5),但是做什么,如果安卓的minSdkVersion =4?有另一种方式?

I load an image into a bitmap and need to know the orientation of taked picture (from camera) to show it correctly. The way to use the following code is working nice (since API Level 5), but what to do if android:minSdkVersion="4"? Is there another way?

ExifInterface exif = new ExifInterface(SourceFileName);     //Since API Level 5
String exifOrientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION);

在此先感谢!

Thanks in advance!

推荐答案

轻松实现自己的<一href="http://stackoverflow.com/questions/2536194/android-image-exif-reader-3rd-party-api/2571105#2571105">exif读者

然后

Metadata metadata = JpegMetadataReader.readMetadata(new File(imagePath));
Directory jpegDirectory = metadata.getDirectory(JpegDirectory.class);
 int height = jpg.GetImageHeight();
 int width = jpg.GetImageWidth();

这篇关于如何确定照片的方向,而不会ExifInterface?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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