Aspect Ratio Calculator

Aspect Ratio Calculator API

Web Development

Calculate aspect ratios for images and videos.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

100 requests per minute

Endpoints

1 endpoint available

Overview

The Aspect Ratio Calculator API computes dimensions based on a given aspect ratio. Provide a ratio (e.g., 16:9) and one known dimension (width or height), and the API calculates the corresponding dimension to maintain the ratio.

How It Works

Given an aspect ratio X:Y and one dimension:

  • If width is known - Height = (width × Y) / X
  • If height is known - Width = (height × X) / Y

Common Aspect Ratios

  • 16:9 - Widescreen HD (1920×1080, 1280×720)
  • 4:3 - Traditional TV/monitors (1024×768)
  • 1:1 - Square (Instagram posts)
  • 21:9 - Ultrawide monitors
  • 9:16 - Vertical video (TikTok, Reels, Stories)
  • 3:2 - Classic photography

Use Cases

  • Responsive image sizing for web development
  • Video thumbnail generation
  • Social media asset creation
  • Print design dimension calculations
  • UI/UX design mockups

Endpoints

POST
/v1/tools/aspect-ratio-calculator
Calculate dimensions based on aspect ratio

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
ratioX
number
Required
The X component of the aspect ratio (e.g., 16 for 16:9)
ratioY
number
Required
The Y component of the aspect ratio (e.g., 9 for 16:9)
dimension
number
Required
The known dimension value in pixels
dimensionType
string
Enum: width, height
Required
Which dimension is provided

Response Example

{
  "success": true,
  "result": {
    "aspectRatio": "16:9",
    "inputDimension": {
      "type": "width",
      "value": 1920
    },
    "calculatedDimension": {
      "type": "height",
      "value": 1080
    },
    "dimensions": {
      "width": 1920,
      "height": 1080
    }
  }
}

Error Codes

400
Invalid request body or missing required parameters
401
Missing or invalid API key
422
Invalid ratio values (must be positive numbers)
429
Rate limit exceeded
500
Internal server error

Code Examples

# Calculate height for 16:9 ratio with width of 1920px
curl -X POST https://api.opentools.ca/v1/tools/aspect-ratio-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ratioX": 16, "ratioY": 9, "dimension": 1920, "dimensionType": "width"}'

# Calculate width for 4:3 ratio with height of 768px
curl -X POST https://api.opentools.ca/v1/tools/aspect-ratio-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ratioX": 4, "ratioY": 3, "dimension": 768, "dimensionType": "height"}'

Ready to get started?

Create an API key to start using the Aspect Ratio Calculator API.