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) 239 B
export const gcd = (a, b) => { return b ? gcd(b, a % b) : a; }; const aspectRatio = (width, height) => { const divisor = gcd(width, height); return `${width / divisor}:${height / divisor}`; }; export default aspectRatio;