jbarlow and GitHub
91c5b1e480
Merge pull request #1613 from bluebox-steven:add-options.work_folder-to-pdfcontext
...
Set work_folder in PdfContext options initialization
2026-04-03 01:28:18 -07:00
James R. Barlow
740f67091c
Rename OCROptions to OcrOptions for consistency
...
Technically OCROptions is more Pythonic but we have several pre-existing classes named OcrWhatever. Go with the local flow.
2026-01-12 23:37:54 -08:00
James R. Barlow
0c3745a1a4
Add OCR engine selection framework and null OCR engine
...
Introduce --ocr-engine option to select between OCR engines:
- 'auto' (default): Uses Tesseract
- 'tesseract': Explicit Tesseract selection
- 'none': Skip OCR entirely (for PDF processing only)
Key changes:
- Extend OcrEngine ABC with generate_ocr() and supports_generate_ocr()
for direct OcrElement tree output (bypasses hOCR)
- Add get_ocr_engine(options) hook parameter for engine selection
- Implement NullOcrEngine for --ocr-engine none
- Export OcrElement, OcrClass, BoundingBox from ocrmypdf package
- Add ocr_tree support to grafting pipeline
This prepares the foundation for pluggable OCR engines while maintaining
full backward compatibility with existing Tesseract-based workflows.
2026-01-12 10:11:14 -08:00
bluebox-steven and GitHub
4babdfcfbf
Set work_folder in JobContext initialization
2026-01-06 09:27:13 +02:00
James R. Barlow and aider
4f9c4c3e52
refactor: reorganize CLI and options initialization
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:48 -08:00
James R. Barlow
08ee5690bc
Remove to_namespace and its user, since nothing triggers it
2025-12-21 12:21:48 -08:00
James R. Barlow
1f493ba789
refactor: post-AI code cleanup
2025-12-21 12:21:47 -08:00
James R. Barlow and aider
3a0a7c546b
feat: Implement JSON serialization for OCROptions with safe handling of Path and stream objects
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:47 -08:00
James R. Barlow and aider
0c3110857e
fix: add lossless_reconstruction to namespace options in PdfContext
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:47 -08:00
James R. Barlow and aider
aad90bcb54
fix: compute lossless_reconstruction when not present in options
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:47 -08:00
James R. Barlow and aider
eeda99636a
fix: handle Namespace conversion in PdfContext initialization
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:47 -08:00
James R. Barlow and aider
dab969f97d
refactor: update context management with OCROptions type hints
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:47 -08:00
James R. Barlow
480a8253eb
refactor: propagate lossless_reconstruction option to clean_options in PageContext
2025-12-21 12:21:47 -08:00
James R. Barlow
d4b7165d72
fix: resolve pickling issue with Pydantic validators in PageContext
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
Fix pickling issue
2025-12-21 12:21:46 -08:00
James R. Barlow and aider
f5bfd2fd3e
Add compat function for pages_from_ranges
...
fix: handle Pydantic validation errors with correct exit code
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:46 -08:00
James R. Barlow and aider
7575dddefc
fix: add lossless_reconstruction attribute to OCROptions for compatibility
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
fix: resolve recursion error in lossless_reconstruction option
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
fix: ensure lossless_reconstruction attribute is added to Namespace
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
fix: ensure lossless_reconstruction attribute is correctly propagated to PageContext
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:42:49 -08:00
James R. Barlow and aider
04ad78f01d
refactor: replace OptimizeOptions with OCROptions in tests
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:41:58 -08:00
James R. Barlow and aider
62c3ae80c7
fix: ensure pickling compatibility for OCROptions in multiprocessing
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:41:58 -08:00
James R. Barlow and aider
d18efcbbf1
fix: support flexible type inputs for pages and unpaper_args
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:41:27 -08:00
James R. Barlow and aider
1579337ebe
refactor: Create OCROptions model with Namespace compatibility
...
This commit introduces a new `OCROptions` class in `_options.py` that provides:
- Proper typing for OCRmyPDF options
- Pydantic validation
- Backward compatibility with `argparse.Namespace`
- Gradual migration support for the options system
Key changes:
- Added comprehensive option fields with type hints
- Implemented custom attribute access methods
- Created conversion methods between Namespace and OCROptions
- Updated type hints in multiple files to support both types
- Maintained existing validation logic
The new model allows for a step-by-step refactoring of the options handling throughout the project.
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:40:57 -08:00
James R. Barlow
6a746a1cbb
ruff linting/Python 3.10 cleanup
2024-02-14 12:41:51 -08:00
James R. Barlow
46a279a49a
Improve passing of arguments to workers
...
The executor system was built around passing only a single
argument to workers, which was
always PageContext. For other tasks, all actual arguments were packed in
a tuple, which meant we needed intermediate functions to unpack the
tuple.
The situation is now rationlized and resembles how Python handles
argument passing to familiar multiprocessing tools.
2023-10-24 00:54:31 -07:00
James R. Barlow
16eb5627a7
Fix unused imports and other trivia
2023-10-24 00:54:31 -07:00
James R. Barlow
fc6f959d21
Refactor debug log and work folder context cleanup
2023-10-24 00:54:30 -07:00
James R. Barlow
113a6b45bd
ruff autofixes (mostly typing.* -> collections.abc.*)
2023-10-01 00:02:53 -07:00
James R. Barlow
5502fb8d9f
jobcontext: typo
2023-04-13 16:04:46 -07:00
James R. Barlow
80ed2117cc
Change to SPDX license tracking
2022-07-28 01:10:07 -07:00
James R. Barlow
dc6f1a266a
Modernize type annotations
2022-07-23 00:39:24 -07:00
James R. Barlow
b17fb61389
Configure pylint in pyproject and delint
2022-06-12 00:30:44 -07:00
James R. Barlow
a0ac448d52
Tidy some old-school %s strings
2022-06-11 00:15:19 -07:00
James R. Barlow
ef1e7a814e
Delinting
2021-01-26 01:45:04 -08:00
James R. Barlow
1084724937
docs: improve API docs
2021-01-26 01:40:40 -08:00
James R. Barlow
aa0ec40102
Change license of all GPLv3 files to MPL-2.0
...
https://github.com/jbarlow83/OCRmyPDF/issues/600
2020-08-05 00:44:42 -07:00
James R. Barlow and James R. Barlow
f4cb424451
Support input/output streams at API level
2020-06-22 02:02:18 -07:00
James R. Barlow
86ec63f215
Decouple plugin manager forking from PdfContext/Pagecontext
2020-06-22 01:16:59 -07:00
James R. Barlow
5b10ec9d39
jobcontext.PdfContext: remove dead code, add annotations
2020-06-22 00:34:58 -07:00
James R. Barlow
a4e88eb8f0
Simplify plugin_manager pickling
2020-06-10 00:41:19 -07:00
James R. Barlow
85cbf94a6e
Convert many uses of str paths to Path
2020-05-06 02:53:47 -07:00
James R. Barlow
c85278b31d
Delinting
2020-05-03 00:53:29 -07:00
James R. Barlow
5dbc080fa0
Rename PDFContext->PdfContext
2020-05-02 04:32:46 -07:00
James R. Barlow
e02f6c1e97
Support plugin invocation with API
2020-05-02 03:34:31 -07:00
James R. Barlow
8d2535e327
Get pluggy to work with forking workers
2020-05-01 02:39:50 -07:00
James R. Barlow
82bce463ae
Start pluggy-based plugin system
2020-05-01 02:15:23 -07:00
James R. Barlow
c2919f2e1c
Reinstate logging of page numbers
2020-04-15 00:05:23 -07:00
James R. Barlow
d146d2b65c
The Great Logging Refactor
...
Remove all instances of logger object being passed as parameters.
This was a holdover from ruffus, and complicated a lot of simple things.
2020-04-14 23:59:33 -07:00
James R. Barlow
8077718804
Possible fix to loss of log adapter state
2019-12-06 15:05:58 -08:00
James R. Barlow
5f00e4f9d8
Sort imports
2019-07-27 04:51:52 -07:00
James R. Barlow
aba293fd80
Change "Temporary working files" output message
2019-06-12 13:56:02 -07:00
James R. Barlow
b9d6e46572
shutil.rmtree: use builtin error suppression
2019-05-31 15:12:46 -07:00
James R. Barlow
ac2fc9c2a0
Explain picklable logger
2019-05-19 15:06:47 -07:00