// 解决IOS上传竖向照片会旋转90度的问题
rotate() {
const that = this;
that.imgOrientation = 1;
let Orientation = null;
const _filelist = $('#showImg')[0].files[0];
$('.weui-uploader__file').removeClass('rotate-90');
$('.weui-uploader__file').removeClass('rotate-180');
$('.weui-uploader__file').removeClass('rotate-90-back');
// 获取图片Orientation参数
EXIF.getData(_filelist, function () {
Orientation = EXIF.getTag(this, 'Orientation');
that.imgOrientation = Orientation;
if (Orientation) {
switch (Orientation) {
case 6: // 正常竖拍
$('.weui-uploader__file').addClass('rotate-90');
break;
case 3: // 横线拍-180
$('.weui-uploader__file').addClass('rotate-180');
break;
case 8: // 竖向拍-180
$('.weui-uploader__file').addClass('rotate-90-back');
break;
default:
$('.weui-uploader__file').removeClass('rotate-90');
$('.weui-uploader__file').removeClass('rotate-180');
$('.weui-uploader__file').removeClass('rotate-90-back');
}
}
});
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章