JSFiddle - React, Tailwind, and code Playground
HTML
<html><body>
<div id="output"></div>
<img src="http://images.nationalgeographic.com/wpf/media-live/photos/000/005/cache/domestic-cat_516_600x450.jpg" id="image">
</body></html>
JavaScript
function gcd(a, b) {
return (b == 0) ? a : gcd(b, a % b);
}
var image = document.getElementById('image');
var w = image.width;
var h = image.height;
var r = gcd(w, h);
var node = document.getElementById('output');
node.innerHTML += "<pre>";
node.innerHTML += "Dimensions = " + w + " x " + h + "<br>";
node.innerHTML += "Gcd = " + r + "<br>";
node.innerHTML += "Aspect = " + w / r + ":" + h / r;
node.innerHTML += "</pre>";