サンプルコード
- naturalWidth , naturalHeight で取得する
- 取得できるのは load イベント発火後
<img id="image" src="./img.png">
<img src="./img.png" onload="check(this)">
<script type="text/javascript">
const target = document.getElementById("image")
function check(t) {
console.log(t.naturalWidth)
console.log(t.naturalHeight)
}
(function() {
if (!target) { return }
target.addEventListener("load", (e) => {
check(e.target)
})
})()
</script>