JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <head>
        <script>
            
        function load(){
            var canvas = document.getElementById("myCanvas");
           
            var ctx = canvas.getContext('2d');
             var img = new Image();
           
            img.src = 'https://developer.mozilla.org/samples/canvas-tutorial/images/rhino.jpg';
            
           img.onload = function(){
   
        ctx.drawImage(img,0,0);
            window.setTimeout(getImageSpecs(img),2000);

      };
}
            function getImageSpecs(img){
            alert(img.width);
            alert(img.height);
            }
window.onload=load;
        </script>
    </head>
    <body>
        <canvas id="myCanvas" width="400" height="228" style="border:1px solid black" ></canvas>
    </body>
</html>