uni.compressImage({ src: src, quality: 30, width: '40%', height:'40%', success: res2 => { // 获取图片信息,配置 canvas 尺寸 uni.getImageInfo({ src: res2.tempFilePath, success: res => { // canvas的相关操作 ...... }, // ios环境在压缩后就不会出现白色图片问题了,应该是ios对于canvas有限制
uni.canvasToTempFilePath 画布保存成图片部分机型会出现空白?是什么原因?使用uni.canvasToTempFilePath 绘制图片,部分机型会出现空白,ios出现率高,第一次生成图片的时候显示空白,偶尔会出现截取图片部分展示,再次上传图片会展示正常,各位大佬们有遇到过吗?怎么解决的? [图片]上传图片白屏; 在开发没复现,都是在用户那边报的。提供了几个账号图片也没复现。 ctxs.draw( false, setTimeout(() => { uni.canvasToTempFilePath( { canvasId: _this.canvasId, fileType: "jpg", width: originWidth, height: originHeight, quality: 1, success: (res) => { let isTempFilePath = res.tempFilePath; resolve(res.tempFilePath) uni.getFileInfo({ filePath:res.tempFilePath, success:imgInfo => { console.log(imgInfo.size, 'quality 前 图片大小sizesize'); uni.compressImage({ src: isTempFilePath, // 图片路径 quality: 1, // 图片压缩质量,0~100,默认80,仅对jpg有效 success: res => { if (index == 1) { let type = 0 if(this.role == 4 ||this.role == 8){ type = 1 } uploadimg(type, res.tempFilePath).then(rps => { this.zhuanghuoimglist.push(rps.message) }) }else if (index == 2){ uploadimg(type, res.tempFilePath).then(rps => { this.danjuimglist.push(rps.message) }) } }) } } } }) }, fail: (err) => { console.log(err) }, complete: () => { uni.hideLoading() } }, that ) }, 1000) )
2024-12-09