Skip to content

fix(ocr): pass render resolution to Tesseract CLI - #5031

Open
mohahf19 wants to merge 4 commits into
docling-project:mainfrom
mohahf19:fix/tesseract-cli-dpi
Open

mohahf19 wants to merge 4 commits into
docling-project:mainfrom
mohahf19:fix/tesseract-cli-dpi

Conversation

@mohahf19

@mohahf19 mohahf19 commented Oct 26, 2026 •

Copy link
Copy Markdown

2 liner + tests

Save DPI metadata in both temporary PNG writes so Tesseract CLI receives the render resolution before orientation detection and after rotation. Without DPI metadata, Tesseract estimates the resolution, which can cause it to misread small text.

Calculate DPI as _POINTS_PER_INCH * scale: Docling uses 72 points per inch, as documented in PdfPageBackend.

Add a PDF pipeline regression test for two scales and both save paths. Local tests and make validate pass; no reference files changed.

Signed-off-by: Mohamad Fakhouri <mohamad.fakhouri@quantco.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @mohahf19, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working ocr labels Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 749713093e. The analysis read the diff only. It did not run code from this pull request.

The PR makes the Tesseract CLI OCR model save DPI metadata (72 * scale) in both temporary PNG writes. It adds a regression test for two scales and for the paths with and without rotation.

CI safety: no concern found. A maintainer must still approve CI.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at 0a7ba5bf6d. It read the code and did not run it.

Minimal two-line fix: both temporary PNG writes in TesseractOcrCliModel.__call__ now include the render DPI. The fix is correct — Pillow writes a pHYs chunk and reads it back — and the regression test covers the orientation==0 path (first save only) and the orientation==90 path (both saves) at two scales. No blockers found; merge when CI passes.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 26, 2026
@mohahf19
mohahf19 marked this pull request as draft October 26, 2026 18:26
Signed-off-by: Mohamad Fakhouri <mohamad.fakhouri@quantco.com>
@github-actions github-actions Bot removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Oct 26, 2026
Signed-off-by: Mohamad Fakhouri <mohamad.fakhouri@quantco.com>
Signed-off-by: Mohamad Fakhouri <mohamad.fakhouri@quantco.com>
@mohahf19
mohahf19 marked this pull request as ready for review October 26, 2026 20:57
@github-actions github-actions Bot added the ai:ci-safe AI triage found no CI-safety concern (advisory) label Oct 26, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the changes since 0a7ba5bf6d at 749713093e. It read the code and did not run it.

I found no defect. Both high_res_image.save(...) calls now pass dpi=(dpi, dpi). The test reads the DPI back from the PNG file that _run_tesseract receives.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working ocr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant