OCRmyPDF’s manual says that when the input is an image rather than a PDF, –image-dpi supplies the DPI instead of the value claimed by the file, and that the option is required when the input does not claim a sensible DPI.
Use the practice file
A practice file, practice-image-input.png. The file is fictional.
| Image | Detail |
|---|---|
| File | practice-image-input.png, a 300 dpi scan saved without DPI metadata |
| Content | One page of text, 12 lines, including the word “harvest” |
| Goal | A searchable PDF with correctly sized text |
The image is the check item: it holds 12 lines and the word “harvest” appears once.
Check the DPI setting
Expected result. We checked the OCRmyPDF manual and the Tesseract manual. We did not run any tool. The checks below are what to expect if the work is done correctly; run them yourself on the practice file.
1. Run without –image-dpi
Run ocrmypdf practice-image-input.png out1.pdf and note any warning about DPI.
Expected result: OCRmyPDF warns about the missing DPI or assumes a value.
2. Run with –image-dpi 300
Run ocrmypdf –image-dpi 300 practice-image-input.png out2.pdf.
Expected result: OCRmyPDF produces the searchable PDF without a DPI warning.
3. Select the word
In out2.pdf, drag across “harvest”.
Expected result: “harvest” highlights exactly.
4. Compare the text size
Open out1.pdf and out2.pdf side by side and select the same word in each.
Expected result: In out2.pdf the highlight fits the word; in out1.pdf it may be too large or too small.
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Run without –image-dpi | OCRmyPDF warns about the missing DPI or assumes a value. | — |
| Run with –image-dpi 300 | OCRmyPDF produces the searchable PDF without a DPI warning. | — |
| Select the word | “harvest” highlights exactly. | — |
| Compare the text size | In out2.pdf the highlight fits the word; in out1.pdf it may be too large or too small. | — |
Related guides: How to Batch OCR a Multi-Page PDF with Consistent Settings — How to Add a Searchable Text Layer to a Scanned PDF.
Limits
- A wrong DPI does not change the words OCR finds, it changes where the invisible text sits — so a word can be found while its highlight lands on the wrong line.
- Command-line OCR rewrites the file, so always work on a copy and keep the original scan untouched.
- UNTESTED — no OCR tool was run; all results above are expected results. The practice file is fictional.
Sources
- OCRmyPDF manual, “ocrmypdf(1) — add an OCR text layer to scanned PDF files” — Modes default, force, skip, redo and strip; –sidecar writes the recognized text; –pages limits OCR to chosen pages. Checked 2026-11-28.
- Tesseract manual, “tesseract(1) — command-line OCR engine” — Default language is English; -l takes 3-character ISO 639-2 codes, joined with + for several languages; –list-langs lists installed packs; –psm sets the page segmentation mode. Checked 2026-11-28.
