OCRmyPDF-ChromeLens-Ocr
OCRmyPDF plugin that uses Google Lens (v1/crupload) as OCR backend.
What It Does
- Sends rasterized page images to Google Lens and parses protobuf response into hOCR + text.
- Preserves hierarchical layout (paragraphs/lines/words), including rotation metadata (
textanglein hOCR lines). - Handles word separators from Lens response for better spacing fidelity.
- Includes optional de-hyphenation for line-broken words.
- Tries to preserve superscript glyphs (for example
¹²³) by overriding OCRmyPDF's NFKC normalization path.
Installation
Prerequisite: install ocrmypdf.
Install from Git:
pip install git+https://github.com/atlantos/OCRmyPDF-ChromeLens-Ocr.git
Install from PyPI:
pip install ocrmypdf-chromelens-ocr
Usage
Basic usage:
ocrmypdf --plugin ocrmypdf_chromelens_ocr input.pdf output.pdf
Debug dump example:
ocrmypdf \
--plugin ocrmypdf_chromelens_ocr \
--keep-temporary-files \
--chromelens-dump-debug \
input.pdf output.pdf
Plugin CLI Options
| Option | Description | Default |
|---|---|---|
--chromelens-no-dehyphenation |
Disable de-hyphenation across adjacent lines. | false |
--chromelens-max-dehyphen-len |
Max prefix/suffix length threshold for de-hyphenation merge. | 10 |
--chromelens-dump-debug |
Write raw request/response + parsed layout artifacts next to *_ocr_hocr.* temp files. Works only with --keep-temporary-files. |
false |
Current Implementation Defaults
These are hardcoded in src/ocrmypdf_chromelens_ocr/plugin.py:
- Upload format:
JPEG - JPEG quality:
95 - Max upload long edge:
- OCRmyPDF v16:
1600 - OCRmyPDF v17+:
1200
- OCRmyPDF v16:
- Fixed request locale/context:
- language
en, regionUS, timezoneAmerica/New_York
- language
- Chrome-style request headers:
x-browser-channel,x-browser-year,x-browser-copyright,x-browser-validation
Note: OCRmyPDF language flags (-l/--language) are not propagated to Lens request context; Lens auto-detection is relied on.
Compatibility
- Python
>=3.9 - OCRmyPDF
>=16.0.0 - Tested with OCRmyPDF 16 and 17 code paths
Limitations
- Uses undocumented/private Google API and may break without notice.
- Requires network access and uploads page images to Google servers.
- OCR quality depends on Lens behavior and can vary by document type.
generate_pdf()in the plugin is not implemented; OCR output is produced through hOCR/text path.
Credits
- chrome-lens-ocr for protobuf/API reverse-engineering ideas.
- OCRmyPDF-AppleOCR for plugin architecture inspiration.
License
MIT
Metadata
Release files for ocrmypdf-chromelens-ocr 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ocrmypdf_chromelens_ocr-1.0.7.tar.gz | 24.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ocrmypdf_chromelens_ocr-1.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.2 kB
Release files / ocrmypdf_chromelens_ocr-1.0.7.tar.gz
| Download URL | ocrmypdf_chromelens_ocr-1.0.7.tar.gz |
|---|---|
| Size | 24.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ca7b14748b27457a68b166a70badebf891d077dd47de036b521090633d39c80
|
|
BLAKE2b-256 checksum How to use checksums |
9ea53114b238ae0414afa994c7598e6b45509e2f1dbf2c05f4702f3cf8b5b797
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 20, 2026.
Transparency logRelease files / ocrmypdf_chromelens_ocr-1.0.7-py3-none-any.whl
| Download URL | ocrmypdf_chromelens_ocr-1.0.7-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ef707de5a9f3e0f059a0c69c49345ab9176710e13cb743939c672478a3dfbf7
|
|
BLAKE2b-256 checksum How to use checksums |
5339f6ebbf7f0ac9dfe03550b278a6b9377f6f416ceb801ba901a3ea01c29e10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 20, 2026.
Transparency log