Understanding the Math
Aspect ratio calculation is based on the principle of direct proportionality. The fundamental formula used in this calculator is:
Where:
$W_1, H_1$ are the base ratio values (e.g., 16 and 9).
$W_2, H_2$ are the actual dimensions in pixels.
To find a missing dimension, we cross-multiply:
To find New Height: $H_2 = \frac{W_2 \times H_1}{W_1}$
To find New Width: $W_2 = \frac{H_2 \times W_1}{H_1}$
Key Features
Bi-directional Calculation: If you change the Width, the Height updates automatically to match the ratio. If you change the Height, the Width follows suit.
GCD Algorithm: Included a Greatest Common Divisor function to "simplify" the ratio at the bottom (e.g., converting 1920:1080 into its simplest 16:9 form).
Ratio Presets: Quick-access chips for industry-standard ratios like Ultrawide (21:9) and Social Media Story (9:16).
Floating Point Support: The
step="any"attribute allows for precise calculations involving decimals.
Aspect Ratio
Adjust any value to maintain the proportion.