How does WeChat Mini Programs change the temporary path of uploading photos into the base64 format of photos?

fff: function () {
    var that = this;
    const ctx = wx.createCanvasContext("myCanvas")
    wx.chooseImage({
      success: function (res) {
        ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100)
        ctx.draw(false, () => {
         wx.canvasGetImageData({
            canvasId: "myCanvas",
            x: 0,
            y: 0,
            width: 100,
            height: 100,
            success(res) {
              console.log(res.width) // 100
              console.log(res.height) // 100
              console.log(res.data instanceof Uint8ClampedArray) // true
              console.log(res.data) // 100 * 100 * 4
              let base64 = wx.arrayBufferToBase64(res.data);
              //console.log(base64)
              that.data.userImageBase64 = "data:image/jpg;base64," + base64;
              console.log(that.data.userImageBase64)
            }
          })
        })
           }
    })
  },

the background of Mini Program"s development is shown in the figure

but this last big code can not convert the correct picture, ask for God"s guidance.

Have you solved the problem of

?


good luck

if you only suggest binary upload for uploading pictures, save volume

Menu