Calculate simplified aspect ratios from pixel dimensions, find missing dimensions from a known ratio, and report decimal and percentage equivalents using GCD simplification.
16:9) and one dimension (width or height), to calculate the missing value16:9)1.7778)177.78%) a. Compute divisor = GCD(width, height) using the Euclidean algorithm: GCD(a, b) = b === 0 ? a : GCD(b, a % b)
b. Simplified ratio: (width / divisor):(height / divisor)
c. Decimal: (width / height).toFixed(4)
d. Percentage: (width / height * 100).toFixed(2)%
a. Parse the ratio as rW:rH
b. If width is given: height = round(width * rH / rW)
c. If height is given: width = round(height * rW / rH)
16:9 → HD Video / Widescreen4:3 → Classic TV / Standard1:1 → Square21:9 → Ultrawide9:16 → Mobile Video / Story3:4 → Portrait Classic3:2 → 35mm Film2:3 → Portrait Photowidth: positive integerheight: positive integerratio: string in W:H format — for Mode Blocked: if true, preserve the current ratio when one dimension changesInput: "What is the aspect ratio of 1920x1080?"
Output:
Input: "I have a 16:9 video, width is 1280px — what height do I need?"
Output:
Input: "Simplify 2560x1440"
Output:
Input: "What is the aspect ratio of 800x600?"
Output:
Input: "Give me height for a 21:9 ultrawide at 2560px width"
Output:
W:H), ask the user to use the W:H format (e.g., 16:9).共 1 个版本