UNPKG

calculate-aspect-ratio

Version:

A simple utility function, and command line utility, for calculating an aspect ratio based on width and height.

14 lines (10 loc) 301 B
"use strict"; exports.__esModule = true; var gcd = exports.gcd = function gcd(a, b) { return b ? gcd(b, a % b) : a; }; var aspectRatio = function aspectRatio(width, height) { var divisor = gcd(width, height); return width / divisor + ":" + height / divisor; }; exports.default = aspectRatio;