pg_ocr
Self-contained OCR functions via PL/Python
pg_ocr · Self-contained OCR functions via PL/Python
Overview
| Relationships | |
|---|---|
| Requires | plpython3u |
Usage
Sources:
- Official upstream README
- Official extension control file (pg_ocr.control)
- Official extension SQL (pg_ocr–0.0.1.sql)
pg_ocr — A PostgreSQL extension for OCR (Optical Character Recognition) — run text recognition on images directly from SQL. No external services needed, just a single SQL query. Use it for the corresponding vector, model, or retrieval workflow. Its extension dependencies must be installed and validated first.
Core Workflow
Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.
Important Objects
pg_ocr(image bytea)is an extension function and returnsjsonb.pg_ocr_from_file(image_path text)is an extension function and returnsjsonb.pg_ocr_get_engine()is an extension function and returnsvoid.pg_ocr_set_model_path(path text)is an extension function and returnsvoid.pg_ocr_setup()is an extension function and returnsvoid.pg_ocr_text(image bytea)is an extension function and returnstext.pg_ocr_text_from_file(image_path text)is an extension function and returnstext.pg_ocr_version()is an extension function and returnstext.
Requirements and Caveats
- The reviewed control file declares default version
0.0.1. - Install the confirmed extension dependencies first:
plpython3u. - The control file marks the extension as relocatable.
- The control file marks the extension as trusted.
- Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.