{
  "schemaVersion": 1,
  "slug": "ppi-calculator",
  "category": "photography",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "e80bd0e7d6c29863130be0afaa2e0ae91f184f9bad2a9de48f7db241a20385b0",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/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 = min(W ÷ pw, H ÷ ph); L = W ÷ Pt; MP = W × H ÷ 10⁶",
    "vars": [
      [
        "W",
        "Image width (px)"
      ],
      [
        "H",
        "Image height (px)"
      ],
      [
        "pw",
        "Print width (in)"
      ],
      [
        "ph",
        "Print height (in)"
      ],
      [
        "Pt",
        "Target PPI"
      ],
      [
        "MP",
        "Megapixels"
      ]
    ],
    "note": "Horizontal PPI = image width / print width; vertical PPI = image height / print height; effective PPI is the lower value. Quality bands are approximate guidance, not a universal sharpness threshold."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const ppiW = printWidth > 0 ? width/printWidth : 0; const ppiH = printHeight > 0 ? height/printHeight : 0; const eff = Math.min(ppiW, ppiH); return { ppiWidth: ppiW, ppiHeight: ppiH, effectivePpi: eff, quality: eff >= 300 ? 'Excellent — gallery quality' : eff >= 200 ? 'Very good' : eff >= 150 ? 'Good at normal reading distance' : eff >= 100 ? 'Acceptable from a distance' : 'Too low — will look soft', maxWidth: width/targetPpi, maxHeight: height/targetPpi, megapixels: width*height/1000000 };",
    "inputs": [
      {
        "name": "width",
        "type": "number",
        "default": 6000,
        "min": 1,
        "max": 200000,
        "step": 1
      },
      {
        "name": "height",
        "type": "number",
        "default": 4000,
        "min": 1,
        "max": 200000,
        "step": 1
      },
      {
        "name": "printWidth",
        "type": "number",
        "default": 20,
        "min": 0.1,
        "max": 10000,
        "step": 0.1
      },
      {
        "name": "printHeight",
        "type": "number",
        "default": 13.33,
        "min": 0.1,
        "max": 10000,
        "step": 0.1
      },
      {
        "name": "targetPpi",
        "type": "select",
        "default": 300,
        "options": [
          {
            "value": 300
          },
          {
            "value": 240
          },
          {
            "value": 150
          },
          {
            "value": 72
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "ppiWidth",
        "precision": 1,
        "unit": "ppi"
      },
      {
        "name": "ppiHeight",
        "precision": 1,
        "unit": "ppi"
      },
      {
        "name": "effectivePpi",
        "precision": 1,
        "unit": "ppi"
      },
      {
        "name": "quality",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "maxWidth",
        "precision": 2,
        "unit": "in"
      },
      {
        "name": "maxHeight",
        "precision": 2,
        "unit": "in"
      },
      {
        "name": "megapixels",
        "precision": 1,
        "unit": "MP"
      }
    ],
    "interpret": null
  }
}
