本来在手机端显示的是旋转的,然后H5端是正常的。然后我通过网上的方法, APP端解决旋转问题了,但是在H5端却也反过来了,头疼啊
网上的方法如下,APP端正常了,H5端却反了,没用之前是H5正常,APP反的,头疼,官方就不能解决下这个BUG?从15年到现在,没人解决
//app端图片翻转
function app_img_rotate(file){
return new Promise((resolve, reject)=>{
uni.getFileInfo({
filePath:file,
success: (da)=> {
// console.log(da);
let rotate = 0;
let quality;
if(300000<da.size<400000){
quality=50;
}else if(400000<=da.size<=500000){
quality=40;
}else if(500000<da.size){
quality=30;
}
uni.getImageInfo({
src: file,
success: (image)=> {
const orientation = image.orientation;
switch (orientation) {
case 'up': //exif:1 不旋转
rotate = 0;
break;
case 'down': //exif:3 旋转180度
rotate = 180;
break;
case 'right': //exif:6 旋转90度
rotate = 90;
break;
case 'left': //exif:8 旋转270度
rotate = 270;
break;
default:
rotate = 0;
break;
}
if(rotate==0){
resolve(file);
}else{
plus.zip.compressImage({
src: file,
dst: "_doc/uniapp_temp" + '/compressed/' + Math.round(new Date()) + '.jpg',
// format: 'jpg',
quality: quality,
width: 'auto',
height: 'auto',
rotate: rotate,
},
function(event) {
resolve(event.target);
},
function(error) {
reject(error);
// console.log(error);
});
}
}
});
}
})
});
}
手机端
H5端
风残落叶 (作者)
?
2020-07-06 09:45