Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Problem with image resolution #1481

Closed
drnicolas opened this issue Feb 19, 2025 · 3 comments
Closed

[Bug]: Problem with image resolution #1481

drnicolas opened this issue Feb 19, 2025 · 3 comments
Assignees

Comments

@drnicolas
Copy link

Describe the bug

I am trying to ocrmypdf a jpg which comes from a ultrasound scanner.
My windows viewer says 96dpi, but ocrmypdf fails with a message that image resolution could not be retrieved

This the traceback:
Traceback (most recent call last): File "/opt/ocr/.vscode/Medistarlinks/link2MEDISTAR.py", line 262, in DoOCR res=ocrmypdf.ocr(filename, output_file=tmpfile+'.pdf',language='deu+eng',title='OCR FAX von '+xxx, \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/ocrmypdf/api.py", line 380, in ocr return run_pipeline(options=options, plugin_manager=plugin_manager) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/ocrmypdf/_pipelines/ocr.py", line 223, in run_pipeline return _run_pipeline(options, plugin_manager) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/ocrmypdf/_pipelines/ocr.py", line 169, in _run_pipeline origin_pdf = triage( ^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/ocrmypdf/_pipeline.py", line 170, in triage triage_image_file(input_file, output_file, options) File "/usr/local/lib/python3.11/dist-packages/ocrmypdf/_pipeline.py", line 97, in triage_image_file raise DpiError( ocrmypdf.exceptions.DpiError: Input file is an image, but has no resolution (DPI) in its metadata. Estimate the resolution at which image was scanned and specify it using --image-dpi.

Is there an ysolution? I cannot change the way the jpg is created

Image

Steps to reproduce

1. Run ocrmypdf -v1 ...arguments... input.pdf output.pdf
2. Open output.pdf
3. ...

Files

No response

How did you download and install the software?

No response

OCRmyPDF version

No response

Relevant log output


@drnicolas drnicolas added the triage Issue needs triage label Feb 19, 2025
@jbarlow83
Copy link
Collaborator

When Windows reports "96 dpi", it probably means that the image contains no DPI information, and Windows guesses a default value of 96 dpi. (Some programs assume 72.)

OCRmyPDF does not make that assumption - there are real world cases where assuming or guessing DPI will give wrong results, and it's best to let the user determine the DPI and enter the correct value.

You can just use ocrmypdf --image-dpi 96 image.png ultrasound.pdf

@github-actions github-actions bot removed the triage Issue needs triage label Feb 19, 2025
@drnicolas
Copy link
Author

Thank you.
Adding this parameter works, but the result is poor.

@jbarlow83
Copy link
Collaborator

In what way is it poor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants