getCanvasImg: function (tempFilePaths) { let that = this; wx.getImageInfo({ src: tempFilePaths, success: function (res) { const SIZE = 300 const ratio = Math.max((res.width/SIZE)*1, (res.height/SIZE)*1, 1) const smallWidth = Math.trunc(res.width / ratio) const smallHeight = Math.trunc(res.height / ratio) console.log('宽度:',smallWidth) console.log('高度:',smallHeight) console.log('缩放比例:',ratio) const ctx = wx.createCanvasContext('photo_canvas'); ctx.drawImage(tempFilePaths, 0, 0, smallWidth, smallHeight); ctx.draw(false, function () { wx.canvasToTempFilePath({ width: smallWidth, height: smallHeight, destWidth: smallWidth, destHeight: smallHeight, canvasId: 'photo_canvas', success: function (res) { console.log(res.tempFilePath) var filePaths = res.tempFilePath console.log(filePaths) that.data.pics || (that.data.pics = []) that.data.pics.push(...filePaths) that.setData({ pics: that.data.pics }) } }) }) } }) },报错信息是: Failed to load local image resource /pages/myProduct/h the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) (env: macOS,mp,1.06.2303220; lib: 2.32.0
时间: 2024-02-19 16:02:00 浏览: 103
微信小程序wx.getImageInfo()如何获取图片信息
这个错误信息看起来与你之前提到的错误信息相同,都是关于加载本地图片资源时出现了问题,返回了一个500内部服务器错误的状态码。在这段代码中,图片路径是通过tempFilePaths参数传递进来的,因此你需要确保该参数的值是正确的图片路径。如果图片路径正确,那么可能是服务器端的问题引起的,你可以联系服务器管理员查看是否有任何问题。同时,也可以尝试清除浏览器缓存或使用其他浏览器来查看是否能够解决问题。
阅读全文