今日开发过程中遇见从相册选择或者自拍照片,显示时为横向。故封装如下代码,希望对大家有所帮助。
function getImgOrientation (filePath) {
var ExifInterface = plus.android.importClass("android.media.ExifInterface");
var exifInterface = new ExifInterface(filePath.replace("file:///", ""));
var orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
var degree = 0;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
return degree;
}
8 个评论
要回复文章请先登录或注册
Error0
Error0
zapoi
1***@qq.com
5***@qq.com
1***@qq.com
trueto
蛋蛋_0713