clipocr
Cross-platform screenshot & clipboard OCR for Python. Powered by RapidOCR. Returns text plus bounding boxes. Works on macOS / Windows / Linux.
Why
You took a screenshot. You want the text out of it — without uploading it anywhere.
clipocr reads the image directly from your clipboard or a file, runs a fast on-device OCR model, and gives you back:
- the recognized text (in reading order),
- a list of
Blocks, each withtext,bbox(xmin, ymin, xmax, ymax) andconfidence, - and overall metadata (engine, image size, average confidence).
Good for: error-screenshot to text, code screenshots, UI mock review, document snippets, anything where you don't want to send your image to a cloud API.
Install
pip install clipocr
The first run downloads ~15 MB of ONNX models into your site-packages (one-time, then cached).
Quick start
Python
from clipocr import ocr, ocr_clipboard
# From a file path
result = ocr("screenshot.png")
print(result.text)
for block in result.blocks:
print(block.bbox, block.text, block.confidence)
# From the system clipboard
result = ocr_clipboard()
print(result.text)
OcrResult is a frozen dataclass:
result.text # str — full text in reading order, joined by "\n"
result.blocks # list[Block] — text + bbox + confidence per region
result.confidence # float — average confidence, 0..1
result.engine # "rapidocr"
result.image_size # (width, height)
result.is_empty # True when no text was found
result.to_dict() # JSON-serializable dict
CLI
clipocr screenshot.png # plain text
clipocr screenshot.png --bbox # text with bounding boxes
clipocr screenshot.png --json # full result as JSON
clipocr --clip # read image from clipboard
clipocr --version
Set CLIPOCR_VERBOSE=1 to keep RapidOCR's INFO logs visible.
Platform notes
| Platform | Clipboard backend |
|---|---|
| macOS | Pillow ImageGrab.grabclipboard() |
| Windows | Pillow ImageGrab.grabclipboard() |
| Linux (Wayland) | wl-paste --type image/png |
| Linux (X11) | xclip -selection clipboard -t image/png -o |
On Linux, install wl-clipboard (Wayland) or xclip (X11) to enable --clip.
Languages
clipocr ships with the default RapidOCR PP-OCRv4 mobile models. They handle:
- Simplified & Traditional Chinese
- English (Latin alphabet)
- Numbers and common punctuation
Mixed Chinese + English content works out of the box.
Development
git clone https://github.com/lidongyangLeo/clipocr.git
cd clipocr
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest # unit tests with coverage
pytest -m integration # also exercise the real RapidOCR engine
ruff check src tests # lint
The test suite enforces ≥ 90% coverage via pytest-cov.
How it works
┌──────────────────┐ ┌─────────────┐ ┌──────────┐
│ image / clipboard │ --> │ RapidOCR │ --> │ OcrResult │
└──────────────────┘ │ (ONNX, on-device) │ └──────────┘
└─────────────┘
clipocr is a thin shim around RapidOCR. It contributes:
- A clean Python API (
ocr/ocr_clipboard/OcrResult). - A cross-platform clipboard adapter.
- Reading-order block sorting (top-to-bottom rows, left-to-right within a row).
- A version-tolerant engine output normalizer (works with both legacy
rapidocr-onnxruntimeand the newrapidocr>= 2.x). - A
clipocrCLI with stdout-clean defaults.
Contributing
Issues and PRs welcome. Please run the tests and ruff check before submitting.
License
MIT — see LICENSE.
Metadata
Release files for clipocr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clipocr-0.1.0.tar.gz | 17.7 kB | With provenance | Details for clipocr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clipocr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for clipocr-0.1.0-py3-none-any.whl |
Total release size: 29.6 kB
Release files / clipocr-0.1.0.tar.gz
| Download URL | clipocr-0.1.0.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd62a51392f88c8fc740be57e88aa5c532779a19d95e5b5b11ec750fe9c1ff9b
|
|
BLAKE2b-256 checksum How to use checksums |
e3c81cd8cafa9f77730b8ee3baba2357291fa0935044ad00f656e2057efc2674
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 17, 2026.
Transparency logRelease files / clipocr-0.1.0-py3-none-any.whl
| Download URL | clipocr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ebb8ecc54e5647f45381fd1c80cfbe97e3bb2d9efd638ff478c7b914e7f4c6a
|
|
BLAKE2b-256 checksum How to use checksums |
82840cf96ac406ccc75bc268857c43ab70504768a2b6c25022646a6c073310f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 17, 2026.
Transparency logSecurity for clipocr 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for clipocr-0.1.0.tar.gz
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 May 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.