使用ExifInterface來獲得方向,如下所示:
File imageFile = new File(imagePath);
ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
boolean isVertical = true ;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
isVertical = false ;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
isVertical =false ;
break;
}
等對所有從屬於ExifInterface文檔中的常量所需要的。
,那麼你可以嘗試做財產以後的使用Picasso API如下:
int imageWidth , imageHeight = 0 ;
if(isVertical) {
imageWidth =1280;
imageHeight=960;
}else if (!isVertical){
imageWidth =960;
imageHeight=1280;
}
Picasso.with(getActivity())
.load(imageUrl)
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.resize(imageWidth , imageHeight)
.centerInside()
.into(imageView);
,並請給我一些反饋。
希望taht幫助。
然後你必須從位圖中創建另一個位圖,你從相機 –