我正在开发一款Android应用程序。在我的应用程序中,我需要捕获一张图片并将该图片发送到服务器。在某些设备上,所捕获的图像在上传到服务器时会旋转90度。我在stackoverflow和其他一些网站上搜索了解决方法。我找到了一些解决方案..我尝试了它们,例如:
Uri selectedImage = data.getData();
File imageFile = new File(selectedImage.toString());
ExifInterface exif;
try {
exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotate=90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate=180;
break;
}
不幸的是,在每个设备上我总是得到方向0。即使在90度旋转的图像设备中也是如此。
请帮助解决我的问题,朋友们。