Open sojusnik opened 5 years ago
--clean-final
does imply --clean
now. It was useless without.
--unpaper-args
implies --clean
but not --clean-final
. As such the awkward parameters in the docs are correct for the moment.
--unpaper-args
might have some practical uses with only --clean
, if you disable mask repositioning and are only trying to improve the OCR quality, but I'm concerned that's a fairly narrow use case. It so happens to be the use case of --clean
on its own.
This is a really messy corner of the interface and I'm not too happy with how it currently works, I've decided. I'll have to see if I can come up with something better. Open to suggestions.
I'm thrilled with the new features for unpaper, so I'm glad to see you're still moving ahead on this functionality. My main usage for this is to split two-up scanned pages into 2 separate pages, removing the black edges and centering/deskewing the text onto two new sheets of paper. (I had a problem with that, but I'll post it under a new case.) If there's a way to bake that functionality into ocrmypdf without needing to use unpaper-args, that would be convenient, as I've been struggling with the args.
Currently thinking:
A new argument --unpaper
will do what --clean --clean-final
does now (clean the presentation and OCR images)
--clean --clean-final --unpaper-args
will all be removed
A new interface will allow plugins, making it possible to write a short script that has the effect of --unpaper-args
. This avoids the messy/error prone nested arguments on the command line and is a lot more powerful. For example Pillow or OpenCV functions could also be used on images. Replicating the existing functionality of --unpaper-args
would be a motivating example.
Sounds reasonable! I'm wondering how user-friendly the approach with the plugins will be: Does someone have to know how to code to use the unpaper parameters, as we have now with --unpaper-args
, or will it be a more or less simple external file with those parameters in it?
It would need to be an external Python script/module that calls unpaper.
Oh. Well, if possible, if you could please leave the "--unpaper-args" option in there, I'd really appreciate it. A separate Python script would significantly increase the complexity for me.
I was able to achieve my desired goals using these commands:
mutool poster -x 2 -y 1 in.pdf out.pdf
ocrmypdf --force-ocr --unpaper-args '--layout single' --deskew --clean-final in.pdf out.pdf
Do I understand correctly that with the python script approach it would be finally possible to split pages with unpaper?
@githubnavigator The idea would be that all of that functionality could be packaged in a short script: ocrmypdf-poster in.pdf out.pdf
.
Generally I want to make it easier for people to customize things and attract more contributions.
I am both working on making ocrmypdf usable as a library and making the library extensible. That should make it easier to implement page splitting, but I don't think would be doable with plugins alone. As it currently looks the way to do that would be use to use components of ocrmypdf as a library in a custom command line driver.
In the release notes it is stated that
In the documentation however the following commands are shown as an example:
So are those examples outdated, or do I misinterpret the statement in the release notes, since in those examples
--clean
could be omitted?Additionally, in another thread you wrote
Do you still plan to implement that?