JS 根据base64获取文件宽高

 

      const {width, height} = await this.getImgSize(base64)

  

 

    async getImgSize(base64) {
      const image = new Image()
      image.crossOrigin = ''
      image.src = base64
      return new Promise((resolve, reject) => {
        image.onload = () => {
          const {width, height} = image
          resolve({width, height})
        }
      })
    },

  

posted @ 2022-11-07 15:14  非帆丶  阅读(252)  评论(0编辑  收藏  举报