OCRmyPDF plugin using Google Lens API for OCR
Project description
OCRmyPDF-ChromeLens-Ocr
A plugin for OCRmyPDF that uses the Google Lens API to perform Optical Character Recognition (OCR).
Features
- High Accuracy: Leverages Google's advanced Lens models.
- Structure Preservation: Correctly handles multi-column layouts and vertical text flows via strict API parsing and rotation-aware sorting.
- Smart De-hyphenation: Merges words broken across lines while respecting punctuation dashes.
⚠️ Compatibility Warning
This plugin is not currently compatible with OCRmyPDF v17 or higher.
OCRmyPDF v17 introduced breaking changes to the plugin interface (migrating from argparse.Namespace to OcrOptions objects). Please use an older version of OCRmyPDF (v16.x or lower) until this plugin is updated.
To install a compatible version:
pip install "ocrmypdf<17"
Installation
Prerequisites
You must have ocrmypdf installed.
Install from Git
pip install git+https://github.com/atlantos/OCRmyPDF-ChromeLens-Ocr.git
Install from Pip
pip install ocrmypdf-chromelens-ocr
Usage
To use this engine, pass the plugin name to OCRmyPDF. You generally do not need to specify a language, as Google Lens auto-detects it.
ocrmypdf --plugin ocrmypdf_chromelens_ocr input.pdf output.pdf
Configuration Options
You can configure the behavior of the plugin using the following command-line arguments:
| Argument | Description | Default |
|---|---|---|
--chromelens-no-dehyphenation |
Disables the logic that merges hyphenated words across lines. Useful if you prefer raw output. | Disabled |
--chromelens-max-dehyphen-len |
The maximum length of word parts allowed for de-hyphenation. If both the prefix (before hyphen) and suffix (after hyphen) are longer than this value, the plugin assumes it is a compound word or dash separator and will not merge them. | 10 |
Example: Disable de-hyphenation
ocrmypdf --plugin ocrmypdf_chromelens_ocr --chromelens-no-dehyphenation input.pdf output.pdf
Example: Stricter de-hyphenation (only merge very short breaks)
ocrmypdf --plugin ocrmypdf_chromelens_ocr --chromelens-max-dehyphen-len 4 input.pdf output.pdf
Credits & Acknowledgements
This project is a Python port and adaptation based on ideas and logic from:
-
- Provided the critical reverse-engineering of the Google Lens Protobuf API (
v1/crupload). - Logic for strict layout parsing and request structure.
- Provided the critical reverse-engineering of the Google Lens Protobuf API (
-
- Provided the architectural inspiration for creating an OCRmyPDF plugin that offloads recognition to an external engine.
Disclaimer
This software is for educational purposes. It uses an undocumented private API from Google.
- Privacy: Your images are uploaded to Google servers. Do not process sensitive/confidential data.
- Stability: The API may change or break at any time without notice.
- Rate Limits: Excessive use may result in your IP being temporarily blocked by Google.
License
MIT License
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.2.tar.gz.
File metadata
- Download URL: ocrmypdf_chromelens_ocr-1.0.2.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f3cf48db6c8e488c7ddbf9228042c0b1c67299b563bcc061e2ca3f3ab672db2
|
|
| MD5 |
3eb1f2e1e149b029949be388e2d49188
|
|
| BLAKE2b-256 |
96839e90f7414a868779dba6d67158f2f8ca73d73cd860ce61db624d70cd4122
|
Provenance
The following attestation bundles were made for ocrmypdf_chromelens_ocr-1.0.2.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.2.tar.gz -
Subject digest:
1f3cf48db6c8e488c7ddbf9228042c0b1c67299b563bcc061e2ca3f3ab672db2 - Sigstore transparency entry: 926790184
- Sigstore integration time:
-
Permalink:
atlantos/OCRmyPDF-ChromeLens-Ocr@4a6762fd381e45966f395519523eac4da814ad93 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/atlantos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a6762fd381e45966f395519523eac4da814ad93 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ocrmypdf_chromelens_ocr-1.0.2-py3-none-any.whl.
File metadata
- Download URL: ocrmypdf_chromelens_ocr-1.0.2-py3-none-any.whl
- Upload date:
- Size: 11.5 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 |
2a7a553a44cbd815d4a415e904e0e573398f439f79431519ca8bdfca3d8a6ee2
|
|
| MD5 |
dea9dd1ec244f26ca7d53ff332f2ea3e
|
|
| BLAKE2b-256 |
bb2fceeb4066e77a3d177ab8854ee050eba46ce0495358c066f2f10265d994ef
|
Provenance
The following attestation bundles were made for ocrmypdf_chromelens_ocr-1.0.2-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.2-py3-none-any.whl -
Subject digest:
2a7a553a44cbd815d4a415e904e0e573398f439f79431519ca8bdfca3d8a6ee2 - Sigstore transparency entry: 926790186
- Sigstore integration time:
-
Permalink:
atlantos/OCRmyPDF-ChromeLens-Ocr@4a6762fd381e45966f395519523eac4da814ad93 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/atlantos
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a6762fd381e45966f395519523eac4da814ad93 -
Trigger Event:
release
-
Statement type: