The aspect ratio of an image is the ratio of the width of the image to its height. Calculate the aspect ratio for particular image dimensions using this simple javascript calculator.
Features
Enter the starting image dimensions on the left, then enter the target dimension on the right.
The javascript calculates the aspect ratio of an image from the given dimensions.
Formula used:(Original Height / Original Width = New Height / New Width.)
Preview
Aspect Ratio Calculator
Enter the starting dimensions on the left, then enter either target dimension on the right. Click Calculate
<!-- Script by hscripts.com --> <!-- More scripts @www.hscripts.com --> <script type="text/javascript"> function aspect_ratio() { var x1=document.getElementById("x1").value; var y1=document.getElementById("y1").value; var gcd=calc(x1,y1); var r1=x1/gcd; var r2=y1/gcd; var ratio=r1+":"+r2; document.getElementById("res").value=ratio; var x2=document.getElementById("x2").value; var y2=document.getElementById("y2").value; var res; var res1; if(x2=="") { res=y2/r2; res1=r1*res; document.getElementById("x2").value=res1.toFixed(2); } else if(y2=="") { res=x2/r1; res1=r2*res;document.getElementById("y2").value=res1.toFixed(2); }}function calc(n1,n2){ var num1,num2; if(n1 < n2) { num1=n1;num2=n2; }else{num1=n2;num2=n1;}var remain=num2%num1;while(remain>0){num2=num1;num1=remain;remain=num2%num1;}return num1; }function reset() {document.getElementById("x1").value="";document.getElementById("y1").value="";document.getElementById("x2").value="";document.getElementById("y2").value=""; } function isInteger(s,iid) {var i;s = s.toString();for (i = 0; i < s.length; i++){var c;if(s.charAt(i)=="."){}else{ c = s.charAt(i);}if (isNaN(c)) { alert("Given value is not a number");document.getElementById(iid).value=""; return false;}}return true; } function ctck() {var sds = document.getElementById("dum");if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}var sdss = document.getElementById("dumdiv");if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");} } document.onload ="ctck()"; </script><!-- Script by hscripts.com -->