Getting width & height of an image with filereader

后端 未结 5 1351
小鲜肉
小鲜肉 2020-11-30 23:36

I am building an image resize/crop, and I\'d like to show a live preview after they\'ve edited it in a modal (bootstrap). This should work, I believe, but I just ge

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 00:12

    fileChangeEventHeader(fileInput) {
        const oFReader = new FileReader();
        oFReader.readAsDataURL(fileInput.target.files[0]);
        oFReader.onload = (event: any) => {
          var image = new Image();
          image.src = event.target.result;
          image.onload = function () {
            console.log(`width : ${image.width} px`, `height: ${image.height} px`);
          };
        };
      }
    
    
    
    

提交回复
热议问题