OCRmyPDF plugin using Google Lens API for OCR
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocrmypdf_chromelens_ocr-1.0.6.tar.gz.
File metadata
- Download URL: ocrmypdf_chromelens_ocr-1.0.6.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d93f2a4edf2defa59bb8fe272fe93f95954df579815e2b63c9517dc08480134
|
|
| MD5 |
cd3e6c4b1fde57a33f65c1986eecca39
|
|
| BLAKE2b-256 |
463d17d70086ac8ece13f0c9edade795cac291517ac4f98cf6c38f4914560f42
|
Provenance
The following attestation bundles were made for ocrmypdf_chromelens_ocr-1.0.6.tar.gz:
Publisher:
release.yml on atlantos/OCRmyPDF-ChromeLens-Ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocrmypdf_chromelens_ocr-1.0.6.tar.gz -
Subject digest:
7d93f2a4edf2defa59bb8fe272fe93f95954df579815e2b63c9517dc08480134 - Sigstore transparency entry: 972809139
- Sigstore integration time:
-
Permalink:
atlantos/OCRmyPDF-ChromeLens-Ocr@f5b596151637ea586d50edc8eb78f7abcc1f0f7c -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/atlantos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f5b596151637ea586d50edc8eb78f7abcc1f0f7c -
Trigger Event:
release
-
Statement type:
File details
Details for the file ocrmypdf_chromelens_ocr-1.0.6-py3-none-any.whl.
File metadata
- Download URL: ocrmypdf_chromelens_ocr-1.0.6-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4883fba81fc58c1729b2880afe230ac1bd2c8da90b034d19161dec410d377892
|
|
| MD5 |
68e7e7879449a783537311d02eff1c14
|
|
| BLAKE2b-256 |
7035867d57dc2a007a581a52229ae4d1405cbe409d31ad009fc546e496cc8ac6
|
Provenance
The following attestation bundles were made for ocrmypdf_chromelens_ocr-1.0.6-py3-none-any.whl:
Publisher:
release.yml on atlantos/OCRmyPDF-ChromeLens-Ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ocrmypdf_chromelens_ocr-1.0.6-py3-none-any.whl -
Subject digest:
4883fba81fc58c1729b2880afe230ac1bd2c8da90b034d19161dec410d377892 - Sigstore transparency entry: 972809143
- Sigstore integration time:
-
Permalink:
atlantos/OCRmyPDF-ChromeLens-Ocr@f5b596151637ea586d50edc8eb78f7abcc1f0f7c -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/atlantos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f5b596151637ea586d50edc8eb78f7abcc1f0f7c -
Trigger Event:
release
-
Statement type: