본문 바로가기
Web Programing!/Script

[Javascript] 이미지 URL로 width, height 구하기

by 어설픈봉봉이 2024. 7. 12.
반응형
SMALL

 

const img = new Image();
img.src = 'url';
img.onload = function() {
  const imgWidth = img.naturalWidth;
  const imgHeight = img.naturalHeight;
  console.log('imgWidth: ', imgWidth);
  console.log('imgHeight: ', imgHeight);
};

 

 

반응형