你是不是用苹果手机上传的?我也遇到这个问题
wx.canvasToTempFilePath()保存图片为空白图片?async drawSaveImage() { console.log("drawImage", this.data.resultData.shareImage,this.data.resultData._qcCodeImage_) const { globalData } = getApp() const shareImage = await globalData.__saveImage const imageQc = await publicMethods.getQcImage(this.data.resultData) console.log("shareImage",shareImage,imageQc) const [$bgImgInfo, $imageQc] = await Promise.all([ publicMethods.getImageInfo(shareImage), publicMethods.getImageInfo(imageQc) ]) const imageBg = globalData.localSaveImageUrl console.log('imageQc', imageQc) console.log('imageBg', imageBg) const canvasContent = wx.createCanvasContext('myCanvas') if (!($imageQc.height && $imageQc.width)) { throw new Error('load qc image fail') } let pox = 1 let imagHeight = $bgImgInfo.height / pox let imageWidth = $bgImgInfo.width / pox console.log("imagHeightaaa", imagHeight, "imageWidth", imageWidth, $bgImgInfo) await this.setCanvasRect(imageWidth, imagHeight) canvasContent.drawImage(imageBg, 0, 0, imageWidth, imagHeight) await canvasContent.draw(true,()=>{}) // 这个比例值 是按照 1500x 2700 的比例算的, 如果图片有放大 或者缩小需要去缩放下 let poxImage = imageWidth / 1500 // if (imageWidth) let qcSize = 235 / pox * poxImage let qcX = imageWidth - qcSize - 40 let qcY = imagHeight - qcSize - 120 const roundRectPadding = 4 qcX = Math.ceil(qcX) qcY = Math.ceil(qcY) qcSize = Math.ceil(qcSize) publicMethods.roundRect(canvasContent, qcX - roundRectPadding, qcY - roundRectPadding, qcSize + roundRectPadding * 2, qcSize + roundRectPadding * 2) canvasContent.drawImage($imageQc.path, qcX, qcY, qcSize, qcSize) await canvasContent.draw(true,()=>{}) await publicMethods.sleep(200) return new Promise((resolve, reject) => { wx.canvasToTempFilePath({ canvasId: 'myCanvas', success: (res) => { resolve(res) }, fail(err) { console.log(err) reject(err) }, complete: (res)=>{ console.log("complete",res) } }) }) },
2023-04-13