Skip to main content

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 (textangle in 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
  • Fixed request locale/context:
    • language en, region US, timezone America/New_York
  • 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

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

ocrmypdf_chromelens_ocr-1.0.5.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocrmypdf_chromelens_ocr-1.0.5-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file ocrmypdf_chromelens_ocr-1.0.5.tar.gz.

File metadata

  • Download URL: ocrmypdf_chromelens_ocr-1.0.5.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ocrmypdf_chromelens_ocr-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5b49c0c04628ca359276793420b4bb46d7dea8ec2780c7ad7765512d1c43c7f0
MD5 1733c3bea12c6f12740c9eea87815db9
BLAKE2b-256 c021bd2c33823b3c66607c667d904a28c513e0bd51e40aa6ce2d2a0417d818e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocrmypdf_chromelens_ocr-1.0.5.tar.gz:

Publisher: release.yml on atlantos/OCRmyPDF-ChromeLens-Ocr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ocrmypdf_chromelens_ocr-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for ocrmypdf_chromelens_ocr-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 91f19e3ced5846d222d6ec7c742064b9d57c6a95ee7eb6c3a7bfaa53b9dbce0d
MD5 f23cf36f9059131b93458418190039c0
BLAKE2b-256 be44de2f1da8f6f23221837d5773b32c52280962946d209bcf4311efaa06f962

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocrmypdf_chromelens_ocr-1.0.5-py3-none-any.whl:

Publisher: release.yml on atlantos/OCRmyPDF-ChromeLens-Ocr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page