Screen Size Calculator API

A lightweight REST API that calculates missing screen properties (width, height, diagonal, aspect ratio, megapixels) when given at least two inputs.

Base URL

https://www.promptbox.cn/api/aspect.php

Method

GET

Query Parameters

Parameter Type Required Example Description
x float No 1920 Screen width (pixels)
y float No 1080 Screen height (pixels)
z float No 22.03 Screen diagonal (same unit as width/height)
ratio string No 16:9 Aspect ratio (colon-separated, e.g. 16:9)

Note: You must provide at least 2 parameters. Units of x, y, z must be consistent.

Response

Success

{
  "success": true,
  "data": {
    "x": 1920,
    "y": 1080,
    "z": 2202.91,
    "ratio": "16:9",
    "megapixels": 2.07
  }
}

Error

{
  "success": false,
  "error": "Need at least 2 inputs"
}

Examples

1. Compute from Width + Height

GET /api/aspect.php?x=1920&y=1080
{
  "success": true,
  "data": {
    "z": 2202.91,
    "ratio": "16:9",
    "megapixels": 2.07
  }
}

2. Compute from Width + Diagonal

GET /api/aspect.php?x=1920&z=2202.91
{
  "success": true,
  "data": {
    "y": 1080,
    "ratio": "16:9",
    "megapixels": 2.07
  }
}

3. Compute from Diagonal + Ratio

GET /api/aspect.php?z=22.03&ratio=16:9
{
  "success": true,
  "data": {
    "x": 19.2,
    "y": 10.8,
    "megapixels": 0.21
  }
}

4. Error Example

GET /api/aspect.php?x=1920
{
  "success": false,
  "error": "Need at least 2 inputs"
}

Notes