javascript get size of image from url code example

Example 1: 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') }
);

Example 2: get data from url javascript

let url = 'https://www.example.com?name=n1&name=n2';
let params = (new URL(url)).searchParams;
params.get('name') // "n1"
params.getAll('name') // ["n1", "n2"]

Example 3: javascript get width of image

image.width

Example 4: javascript get image dimensions

var img = document.getElementById("myImageID"); 
var imgWidth = img.clientWidth;
var imgHeight = img.clientHeight;