Answers for "get image size javascript"

2

how to get img dimensions from remote url js

function getMeta(url, callback) {
    var img = new Image();
    img.src = url;
    img.onload = function() { callback(this.width, this.height); }
}
getMeta(
  "http://snook.ca/files/mootools_83_snookca.png",
  function(width, height) { alert(width + 'px ' + height + 'px') }
);
Posted by: Guest on January-25-2020
1

javascript get image width and height

var img = new Image();
img.onload = function() {
  alert(this.width + 'x' + this.height);
}
img.src = 'http://www.google.com/intl/en_ALL/images/logo.gif';
Posted by: Guest on March-04-2020
0

get image file width javascript

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Get image width using File API</title>
  </head>

  <body>
    <input type='file' onchange="readURL(this);" />

    <script>
      function readURL(input) {
        if (input.files && input.files[0]) {
          var reader = new FileReader();
          reader.onload = function (e) {
            var img = new Image;
            img.onload = function() {
              console.log("The width of the image is " + img.width + "px.");
            };
            img.src = reader.result;
          };
          reader.readAsDataURL(input.files[0]);
        }
      }
    </script>
  </body>
</html>
Posted by: Guest on April-05-2020
1

javascript get image dimensions

var img = document.getElementById("myImageID"); 
var imgWidth = img.clientWidth;
var imgHeight = img.clientHeight;
Posted by: Guest on July-31-2019
0

javascript get width of image

image.width
Posted by: Guest on July-01-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language