Calculate Aspect Ratio
This site uses the calculate-aspect-ratio
NPM module
that calculates the aspect ratio with the provided width
and height
.
import calculateAspectRatio from 'calculate-aspect-ratio';
const aspectRatio = calculateAspectRatio(1920, 1080); // '16:9'
In addition to being able to use it in your Javascript projects, it also comes with a handy command line utility for being able to quickly calculate the aspect ratio from the command line.
$ aspectratio 1920 1080
Aspect ratio: 16:9
You can check it out on NPM and GitHub.