{"record":{"id":"727b9bfaacfb10ce","repo":"ocrmypdf/OCRmyPDF","slug":"input-file-is-an-image-but-the-resolution-dpi-i","errorCode":null,"errorMessage":"Input file is an image, but the resolution (DPI) is not credible.  Estimate the resolution at which the image was scanned and specify it using --image-dpi.","messagePattern":"Input file is an image, but the resolution \\(DPI\\) is not credible\\.  Estimate the resolution at which the image was scanned and specify it using --image-dpi\\.","errorType":"error_code","errorClass":"DpiError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/_pipeline.py","lineNumber":110,"sourceCode":"        # Recover the original filename\n        log.error(str(e).replace(str(input_file), str(options.input_file)))\n        if not input_file.exists():\n            log.error(\"Input file does not exist: %s\", input_file)\n        if input_file.is_dir():\n            log.error(\"Input file is a directory: %s\", input_file)\n        if input_file.is_file():\n            log.error(\"Input file is a file: %s\", input_file)\n        if input_file.stat().st_size == 0:\n            log.error(\"Input file is empty: %s\", input_file)\n        raise UnsupportedImageFormatError() from e\n\n    with im:\n        log.info(\"Input file is an image\")\n        if 'dpi' in im.info:\n            if im.info['dpi'] <= (96, 96) and not options.image_dpi:\n                log.info(\"Image size: (%d, %d)\", *im.size)\n                log.info(\"Image resolution: (%d, %d)\", *im.info['dpi'])\n                raise DpiError(\n                    \"Input file is an image, but the resolution (DPI) is \"\n                    \"not credible.  Estimate the resolution at which the \"\n                    \"image was scanned and specify it using --image-dpi.\"\n                )\n        elif not options.image_dpi:\n            log.info(\"Image size: (%d, %d)\", *im.size)\n            raise DpiError(\n                \"Input file is an image, but has no resolution (DPI) \"\n                \"in its metadata.  Estimate the resolution at which \"\n                \"image was scanned and specify it using --image-dpi.\"\n            )\n\n        if im.mode in ('RGBA', 'LA'):\n            raise UnsupportedImageFormatError(\n                \"The input image has an alpha channel. Remove the alpha channel first.\"\n            )\n\n        if 'iccprofile' not in im.info:","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/_pipeline.py#L92-L128","documentation":"Raised by triage_image_file when a raw image input has DPI metadata that is <= (96, 96), which is almost certainly a default/guessed value rather than a real scan resolution. OCR quality depends on knowing the true DPI, so ocrmypdf refuses to guess.","triggerScenarios":"Feeding a JPEG/PNG/TIFF image (not PDF) whose embedded dpi metadata is 96x96 or lower, without specifying --image-dpi; occurs during triage before PDF conversion.","commonSituations":"Images exported from phones/screenshots/web downloads that carry a default 96 DPI tag; scanned images whose metadata was stripped.","solutions":["Determine the real scan resolution and pass --image-dpi (e.g. --image-dpi 300)","Re-save the image with correct DPI metadata embedded","Convert the image to PDF first with the correct DPI (e.g. via img2pdf)"],"exampleFix":"# before\nocrmypdf scan.jpg out.pdf\n# after\nocrmypdf --image-dpi 300 scan.jpg out.pdf","handlingStrategy":"validation","validationCode":"from PIL import Image\nwith Image.open(src) as im:\n    dpi = im.info.get('dpi')\n    if dpi and tuple(dpi) <= (96, 96) and not image_dpi:\n        image_dpi = 300  # ask user or assume scan default","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect image dpi metadata in your ingestion step and prompt for --image-dpi when it looks defaulted"],"tags":["ocr","ocrmypdf","image-metadata","dpi"],"backgroundTag":"missing-image-metadata","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}