{
  "id": "aspect-ratio",
  "version": "490832a00953",
  "status": "published",
  "name": "Aspect Ratio Calculator",
  "question": "What is my aspect ratio?",
  "summary": "Finds the aspect ratio of a width and height in lowest terms (1920 × 1080 is 16:9) with the closest common ratio, or resizes to a ratio from a new width or height.",
  "category": "math",
  "subcategory": "arithmetic",
  "url": "https://www.acalculator.org/math/aspect-ratio-calculator",
  "markdown": "https://www.acalculator.org/math/aspect-ratio-calculator.md",
  "kind": "function",
  "method": "Aspect ratio = width : height, divided by their greatest common divisor; a new height is new width × H ÷ W (and a new width is new height × W ÷ H).",
  "assumptions": [
    "Width and height are positive numbers in one unit, usually pixels; decimals are read exactly (2.39 is 239/100).",
    "Resizing keeps the ratio exactly, so a solved side may not be a whole number of pixels.",
    "The closest common ratio is the nearest of 1:1, 5:4, 4:3, 3:2, 16:10, 16:9, 1.85:1, 2:1, 21:9, and 2.39:1, flipped for a portrait size."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "mode": {
        "title": "I want to",
        "description": "Find the ratio of a size, or resize to a ratio from a new width or a new height.",
        "type": "string",
        "enum": [
          "ratio",
          "width",
          "height"
        ]
      },
      "w": {
        "title": "Width",
        "description": "The width of the screen, image, or video, in pixels or any unit.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "h": {
        "title": "Height",
        "description": "The height, in the same unit as the width.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "rw": {
        "title": "Ratio width",
        "description": "The first number of the ratio W:H, such as 16 in 16:9.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "rh": {
        "title": "Ratio height",
        "description": "The second number of the ratio W:H, such as 9 in 16:9.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "nw": {
        "title": "New width",
        "description": "The width you want; the height is found from the ratio.",
        "type": "number",
        "exclusiveMinimum": 0
      },
      "nh": {
        "title": "New height",
        "description": "The height you want; the width is found from the ratio.",
        "type": "number",
        "exclusiveMinimum": 0
      }
    }
  },
  "outputs": {
    "ratio": {
      "label": "Aspect ratio",
      "description": "Width : height in lowest whole-number terms.",
      "format": "text"
    },
    "width": {
      "label": "Width",
      "description": "The width of the size.",
      "format": "number"
    },
    "height": {
      "label": "Height",
      "description": "The height of the size.",
      "format": "number"
    },
    "decimal": {
      "label": "Ratio as a decimal",
      "description": "Width ÷ height, the ratio written as x:1.",
      "format": "number"
    },
    "common": {
      "label": "Closest common ratio",
      "description": "The common aspect ratio nearest to this one, such as 16:9 or 4:3.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "mode": "ratio",
      "w": 1920,
      "h": 1080,
      "rw": 16,
      "rh": 9,
      "nw": 1280,
      "nh": 720
    },
    "outputs": {
      "ratio": "16:9",
      "width": 1920,
      "height": 1080,
      "decimal": 1.7777777777777777,
      "common": "16:9"
    },
    "text": "A size of 1,920 × 1,080 has an aspect ratio of 16:9."
  },
  "examples": [
    {
      "given": {
        "mode": "ratio",
        "w": 1920,
        "h": 1080
      },
      "expect": {
        "ratio": "16:9",
        "decimal": 1.7777777777777777,
        "common": "16:9"
      },
      "source": "ITU-R Recommendation BT.709-6, 1920 × 1080 at 16:9 (https://www.itu.int/rec/R-REC-BT.709); hand calculation in content.mdx: gcd(1920, 1080) = 120, 1920 ÷ 120 = 16, 1080 ÷ 120 = 9"
    },
    {
      "given": {
        "mode": "ratio",
        "w": 1366,
        "h": 768
      },
      "expect": {
        "ratio": "683:384",
        "decimal": 1.7786458333333333,
        "common": "16:9"
      },
      "source": "hand calculation in content.mdx: gcd(1366, 768) = 2; Python 3: 1366/768, math.gcd(1366, 768)"
    },
    {
      "given": {
        "mode": "ratio",
        "w": 1080,
        "h": 1920
      },
      "expect": {
        "ratio": "9:16",
        "common": "9:16"
      },
      "source": "hand calculation in content.mdx: a portrait phone screen, 1080 ÷ 120 = 9, 1920 ÷ 120 = 16"
    },
    {
      "given": {
        "mode": "width",
        "rw": 16,
        "rh": 9,
        "nw": 1280
      },
      "expect": {
        "height": 720,
        "width": 1280,
        "ratio": "16:9"
      },
      "source": "hand calculation in content.mdx: 1280 × 9 ÷ 16 = 720"
    },
    {
      "given": {
        "mode": "height",
        "rw": 4,
        "rh": 3,
        "nh": 1000
      },
      "expect": {
        "width": 1333.3333333333333,
        "ratio": "4:3"
      },
      "source": "hand calculation in content.mdx: 1000 × 4 ÷ 3 = 4000/3; Python 3: 4000/3"
    },
    {
      "given": {
        "mode": "ratio",
        "w": 2.39,
        "h": 1
      },
      "expect": {
        "ratio": "239:100",
        "decimal": 2.39,
        "common": "2.39:1"
      },
      "source": "hand calculation in content.mdx: 2.39 is read exactly as 239/100"
    }
  ],
  "sources": [
    "SMPTE ST 2036-1:2014, Ultra High Definition Television: Image Parameter Values for Program Production (16:9 aspect ratio, 3840 × 2160 and 7680 × 4320).",
    "ITU-R Recommendation BT.709-6 (2015), Parameter values for the HDTV standards (16:9, 1920 × 1080). https://www.itu.int/rec/R-REC-BT.709",
    "OpenStax, Prealgebra 2e, §6.5 Solve Proportions and their Applications (equal ratios, cross products). https://openstax.org/books/prealgebra-2e/pages/6-5-solve-proportions-and-their-applications"
  ],
  "related": [
    "ratio",
    "proportion",
    "fraction",
    "percentage"
  ],
  "changelog": []
}
