uniapp 压缩照片

compressAction = new Promise((resolve, reject) => {
    
    
	let path = val.path;
	plus.zip.compressImage({
    
    
		src: path, //原路径
		dst: path, //缩略图路径
		overwrite: true, //是否生成新图片
		quality: 20, //1-100,1图片最小,100图片最大
		width: 'auto', //缩略固定宽
		height: 'auto' //缩略固定高
	},
	(result) => {
    
    
		lists.push({
    
    
			url: result.target,
			progress: 0,
			error: false
		});
		resolve(lists)
	}),
	(error) => {
    
    
		lists.push({
    
    
			url: path,
			progress: 0,
			error: false
		});
		reject(lists)
	}
});

猜你喜欢

转载自blog.csdn.net/weixin_42998230/article/details/108884046