{
  "schemaVersion": 1,
  "slug": "dpi-ppi-calculator",
  "category": "everyday",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "3b297008c040612d95396e969b6e458eabb61df3aca1b44a3ffa878f263c215a",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/dpi-ppi-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "PPI = √(w² + h²) ÷ D; MP = w × h ÷ 1000000",
    "vars": [
      [
        "w",
        "horizontal pixels"
      ],
      [
        "h",
        "vertical pixels"
      ],
      [
        "D",
        "screen diagonal, inches"
      ],
      [
        "PPI",
        "pixels per inch"
      ],
      [
        "MP",
        "megapixels"
      ]
    ],
    "note": "Print size at the target ppi is w÷PPI_t by h÷PPI_t inches (×2.54 for cm); the quality note follows MP bands 6/12/20."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const diagPx = Math.sqrt(screenWidthPx*screenWidthPx+screenHeightPx*screenHeightPx); const ppi = screenDiagonal > 0 ? diagPx/screenDiagonal : 0; const megapixels = widthPx*heightPx/1000000; const printWidth = targetPpi > 0 ? widthPx/targetPpi : 0; const printHeight = targetPpi > 0 ? heightPx/targetPpi : 0; const note = 'Print dimensions are estimates; perceived sharpness depends on viewing distance, printer, and image.'; return { ppi, megapixels, printWidth, printHeight, printWidthCm: printWidth*2.54, qualityNote: note };",
    "inputs": [
      {
        "name": "widthPx",
        "type": "number",
        "default": 4000,
        "min": 1,
        "max": 100000,
        "step": 1
      },
      {
        "name": "heightPx",
        "type": "number",
        "default": 6000,
        "min": 1,
        "max": 100000,
        "step": 1
      },
      {
        "name": "screenDiagonal",
        "type": "number",
        "default": 27,
        "min": 1,
        "max": 200,
        "step": 0.1,
        "slider": true
      },
      {
        "name": "screenWidthPx",
        "type": "number",
        "default": 5120,
        "min": 1,
        "max": 20000,
        "step": 1
      },
      {
        "name": "screenHeightPx",
        "type": "number",
        "default": 2880,
        "min": 1,
        "max": 20000,
        "step": 1
      },
      {
        "name": "targetPpi",
        "type": "number",
        "default": 300,
        "min": 30,
        "max": 1200,
        "step": 10,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "ppi",
        "precision": 1,
        "unit": "ppi"
      },
      {
        "name": "megapixels",
        "precision": 1,
        "unit": "MP"
      },
      {
        "name": "printWidth",
        "precision": 2,
        "unit": "in"
      },
      {
        "name": "printHeight",
        "precision": 2,
        "unit": "in"
      },
      {
        "name": "printWidthCm",
        "precision": 1,
        "unit": "cm"
      },
      {
        "name": "qualityNote",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
