Metadata-Version: 2.5
Name: actum-ocr
Version: 0.1.0
Summary: Document image OCR via OpenAI vision — extract plain text from JPEG/PNG/WebP.
Project-URL: Homepage, https://github.com/example/actum-ocr
Project-URL: Documentation, https://github.com/example/actum-ocr#readme
Author: Actum
License: MIT
License-File: LICENSE
Keywords: actum,document,ocr,openai,vision
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Requires-Python: >=3.10
Requires-Dist: openai<2,>=1.40
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Description-Content-Type: text/markdown

# actum-ocr

Document image OCR via OpenAI vision. Extract plain text from JPEG / PNG / WebP.

## Install

```bash
pip install actum-ocr
```

Local / editable (from this folder):

```bash
pip install -e .
# or build artifacts:
python -m build
pip install dist/actum_ocr-*.whl
```

## Usage

```python
import base64
from actum_ocr import extract_text_from_image, resolve_source_text, OcrError

with open("passport.jpg", "rb") as f:
    b64 = base64.b64encode(f.read()).decode("ascii")

text = extract_text_from_image(b64, "image/jpeg")
# or: text, ocr_used = resolve_source_text(image_base64=b64, image_mime="image/jpeg")
```

Optional kwargs (override env):

```python
extract_text_from_image(
    b64,
    "image/png",
    api_key="sk-...",
    model="gpt-4o-mini",
    timeout=120,
    detail="low",  # low | high | auto
)
```

## Environment

| Variable | Default | Purpose |
|---|---|---|
| `OPENAI_API_KEY` | — | Required unless `api_key=` is passed |
| `ACTUM_OCR_MODEL` / `ACTUM_MODEL` | `gpt-4o-mini` | Vision model |
| `ACTUM_OCR_TIMEOUT` | `120` | Request timeout (seconds) |
| `ACTUM_OCR_DETAIL` | `low` | Vision detail: `low` / `high` / `auto` |

## Publish to PyPI

```bash
pip install build twine
python -m build
twine upload dist/*
```

For TestPyPI first:

```bash
twine upload --repository testpypi dist/*
pip install -i https://test.pypi.org/simple/ actum-ocr
```

## API

- `ocr_available()` — key present?
- `decode_image(b64, mime)` — validate + decode
- `extract_text_from_image(b64, mime, **opts)` — OCR → text
- `resolve_source_text(text=..., image_base64=..., image_mime=..., **opts)` — image wins
- `OcrError` — `.code`, `.message`, `.status_code`
