UNPKG

calculate-aspect-ratio

Version:

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

11 lines (8 loc) 249 B
export var 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; }; export default aspectRatio;