How to show the dimensions of a document as a ratio

When we are using Image size window, width and height is displayed in percentage, pixel, inches etc. I need to get a pop up window showing the dimension of the document in ratios. Is this possible?

Answer

Here is a quick script that will calculate the ratio of the currently open document:

#target photoshop
var doc = app.activeDocument;

var ratio = reduce(doc.width.value, doc.height.value);
alert(ratio[0]+':'+ratio[1])

// by Phrogz see:
// http://stackoverflow.com/questions/4652468/
function reduce(numerator,denominator){
  var gcd = function gcd(a,b){
    return b ? gcd(b, a%b) : a;
  };
  gcd = gcd(numerator,denominator);
  return [numerator/gcd, denominator/gcd];
}

Attribution
Source : Link , Question Author : Manu Gopinath , Answer Author : joojaa

Leave a Comment