Skip to content

Instantly share code, notes, and snippets.

@mattocchi
Created March 19, 2020 07:55
Show Gist options
  • Select an option

  • Save mattocchi/96df27ccc24fe48b46decd0618e0d349 to your computer and use it in GitHub Desktop.

Select an option

Save mattocchi/96df27ccc24fe48b46decd0618e0d349 to your computer and use it in GitHub Desktop.
leggere dimensioni originali immagine da javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Find Real Image Width and Height</title>
<script>
function imgSize() {
var myImg = document.querySelector("#sky");
var realWidth = myImg.naturalWidth;
var realHeight = myImg.naturalHeight;
alert("Original width=" + realWidth + ", " + "Original height=" + realHeight);
}
</script>
</head>
<body>
<img src="https://test.aleven.it/KatiaServer/images/generic/katiaserver-trasp.png" id="sky" width="250" alt="Cloudy Sky">
<p><button type="button" onclick="imgSize();">Get Original Image Size</button></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment