你好 你可以看下私信吗 我想向你请教个问题
canvas 压缩图片问题?const ctx = wx.createCanvasContext('CanvasId'); console.log(this.data.front)//图片临时地址 wx.getImageInfo({ src: this.data.front, success: (res) => { var ratio = this.data.pixelRatio if (res.width > size) { // 判断图片是否超过300像素 // var scale = res.height / res.width this.setData({ cWidth:Math.trunc(res.width / ratio), cHeight:Math.trunc(res.height / ratio) }) // 画出压缩图片 ctx.drawImage(this.data.front, 0, 0, this.data.cWidth, this.data.cHeight); ctx.draw(false, setTimeout(() => { wx.canvasToTempFilePath({ canvasId: 'CanvasId', fileType: 'jpg', quality:1, success: (res) => { console.log(res.tempFilePath) }, fail: (res) => { console.log(res) } }) },300) ) } }); 压缩的图片比原来的图片还大,不知道怎么回事
2020-07-15