Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Find Real Image Dimensions</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var img = $("#sky"); // Create dummy image to get real size $("<img>").attr("src", $(img).attr("src")).load(function(){ var realWidth = this.width; var realHeight = this.height; alert("Original width=" + realWidth + ", " + "Original height=" + realHeight); }); }); }); </script> </head> <body> <img src="/examples/images/sky.jpg" id="sky" width="250" alt="Cloudy Sky"> <p><button type="button">Get Original Image Size</button></p> </body> </html>