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

PDF Renderer: allow to specify an alternate image or a custom resolution. #4171

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

phymbert
Copy link

@phymbert phymbert commented Dec 19, 2023

Motivation

Input images passed to OCR are often pre-processed (higher resolution, grayed, etc...).
It can be useful to specify an alternate image or a lower resolution in renderer, especially for a searchable pdf export.

Proposed changes

  1. Added TessResultRenderer::SetRenderingImage or TessResultRenderer::SetRenderingResolution methods allow to programmatically change image or resolution to render before adding image to the renderer
  2. New rendering_dpi param allows to override the output resolution by scaling the source image
  3. Added few pdfrenderer tests
  4. Fix missing pdf.ttf font in the cmake install target

These changes might resolve #210 and #3798 features request.

Checks

  • make check passed locally on ubuntu 23.10
  • GitHub workflows passed

phymbert added a commit to phymbert/tesseract that referenced this pull request Dec 20, 2023
@zdenop
Copy link
Contributor

zdenop commented Dec 20, 2023

cmake does not install a PDF font file. It was the old way, how to handle font in pdf. Now it is automatically included in library

@zdenop
Copy link
Contributor

zdenop commented Dec 20, 2023

@jbreiden @jbreiden2 : Jeff can you have a look at this?

@phymbert
Copy link
Author

phymbert commented Dec 20, 2023

cmake does not install a PDF font file. It was the old way, how to handle font in pdf. Now it is automatically included in library

Thanks, @zdenop, for the explanation. I was confused with the tessdata/Makefile.am, and I will remove it.
Let me submit pdfrendrerer test fixes, it failed on some platforms.

@jbreiden @jbreiden2, a better way to check pdf files generated than file maximum size is welcomed

@phymbert phymbert marked this pull request as ready for review February 17, 2024 18:00
@phymbert
Copy link
Author

It looks there is a little interest, that happens :) Thanks all

@phymbert phymbert closed this Apr 14, 2024
@stweil
Copy link
Member

stweil commented Apr 14, 2024

Hi, it's not unusual that pull requests take some time before they are merged. That does not necessarily mean that there is little interest, but there is only a small number of people who contribute to pull requests by adding comments or testing them.

@phymbert phymbert reopened this Apr 14, 2024
@phymbert
Copy link
Author

No worries at all, I just saw it open on my to-do list for a while, so I preferred to close. Thanks for your feedback, I understand, reopened, no hurry.

@zdenop zdenop added this to the 5.4.0 milestone Apr 18, 2024
@zdenop
Copy link
Contributor

zdenop commented Apr 18, 2024

Since it extends the API functionality, it should be included in the 5.4.0 release.

…ammatically

Support new rendering_dpi api params.
Add pdf renderer tests.
Install pdf font in cmake tool chain.

resolves tesseract-ocr#210
resolves tesseract-ocr#3798
@stweil stweil force-pushed the phymbert/features/3798-rendering-resolution-option branch from 13bccc0 to 94b95b1 Compare April 19, 2024 19:34
@stweil
Copy link
Member

stweil commented Apr 19, 2024

I rebased this pull request and fixed a merge conflict.

@zdenop
Copy link
Contributor

zdenop commented Apr 19, 2024

What about implementing this feature also to tesseract executable as a command line option?

@stweil
Copy link
Member

stweil commented Apr 20, 2024

Isn't that already possible with -c?

pdf: tests add lib leptonica dependency in the make toolchain
@zdenop
Copy link
Contributor

zdenop commented Apr 20, 2024

Isn't that already possible with -c?

With -c I can set rendering_dpi. How can I set an image for SetRenderingImage?

zdenop referenced this pull request May 12, 2024
zdenop referenced this pull request May 19, 2024
@stweil
Copy link
Member

stweil commented May 19, 2024

Tesseract can create multi-page PDF files when it is called with a list of images. Ideally that should also work with alternate images.

@stweil
Copy link
Member

stweil commented May 19, 2024

Isn't that already possible with -c?

With -c I can set rendering_dpi. How can I set an image for SetRenderingImage?

Would it be possible to implement the desired features by only adding new Tesseract parameters – without any change of the C / C++ API?

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

Successfully merging this pull request may close these issues.

Feature request: Add optional input for alternate image to use when sandwiching OCR data
3 participants