Skip to main content

Archive file trees to compact, OCR-friendly printable pages (text/PDF/docx) and restore them from scans.

Project description

glyphive

Status: alpha Python 3.9+ License: MIT Docs CI

Archive a file tree to compact, OCR-friendly, printable pages and restore it from a transcript or scan. Glyphive keeps the paper representation human-readable while using checksums and error correction to detect or repair the character errors that make ordinary base64-on-paper fragile.

Status: alpha. The wire format and CLI may change before 1.0.

Features

  • Printable text, PDF, or Word output with selectable font family and size.
  • Bundled OCR-B PDF option under the SIL Open Font License, plus custom .ttf/.otf PDF font paths for measured channels.
  • Measured OCR-safe base16c-crc16-rs alphabet (ABCDHKLMPRTVXY34) with no confusable character aliases.
  • Localized integrity checks on every encoded line and protected page metadata.
  • Document-wide Reed-Solomon parity for correcting scattered OCR errors.
  • Optional whole-page recovery (--parity-pages K, default off): survives up to K wholly lost/unscannable pages, independent of the per-line parity.
  • Binary-safe archives for nested trees, empty directories, and arbitrary file contents.
  • Deterministic restore from text; optional OCR providers are loaded only when image input is requested.

Installation

pip install glyphive

Optional features:

Extra Adds Needed for
pdf fpdf2 PDF output
docx python-docx Word (.docx) output
zstd zstandard zstd compression
ocr Pillow, pytesseract Tesseract image bridge; the Tesseract program is installed separately
qr segno, zxing-cpp, Pillow QR envelope generation and image decoding without OpenCV
all all packages above All lightweight integrations

Glyphive requires pathlib_next>=0.8.1 and Python 3.9 or newer.

Quick start

Create a text archive from one directory, inspect it, and restore it:

glyphive create -f backup.txt --compression gzip -C project .
glyphive list -f backup.txt
glyphive inspect -f backup.txt          # recovery-headroom report (read-only)
glyphive extract -f backup.txt -C restored

Restore or inspect an already-generated GQ1 QR image set explicitly with glyphive extract -f qr-pages/ --from-qr -C restored or glyphive list -f qr-pages/ --from-qr. Ordinary image input continues through OCR; QR mode requires glyphive[qr] and rejects mixed, duplicate, corrupt, or incomplete symbol sets before writing files.

Create QR-only or hybrid human-readable/QR PDF pages with an explicit format:

glyphive create -f backup.pdf --format qr -C project .
glyphive create -f backup-hybrid.pdf --format hybrid -C project .

A .pdf filename without --format remains the ordinary text PDF renderer; the suffix cannot distinguish PDF, QR, and hybrid presentations.

Tar-style mode flags are equivalent when a positional command is inconvenient:

glyphive -c -f backup.txt -C project .
glyphive -t -f backup.txt
glyphive -x -f backup.txt -C restored

Installed plugins

Glyphive can explicitly discover implementations supplied by installed Python distributions. Pass the global --plugins flag to opt in for that invocation:

glyphive --plugins create -f backup.txt --codec vendor_codec -C project .

Plugin distributions register a concrete typed class under one of these entry point groups:

Entry-point group Required base class
glyphive.codecs glyphive.codec.Codec
glyphive.compression glyphive.compression.CompressionMethod
glyphive.render_formats glyphive.render.RenderFormat
glyphive.ocr_providers glyphive.restore.ocr.OcrProvider

The entry-point name must exactly match the class's lowercase registry name. Library callers use glyphive.plugins.discover(); normal imports and registry lookups never discover plugins. Discovery is deterministic and cached, and a bad candidate is reported without preventing valid candidates from loading.

Installed plugin code executes with the same permissions as Glyphive and is not sandboxed. Use --plugins only when you trust every installed distribution that declares one of these groups. Discovery does not download or update code.

Create a PDF instead:

pip install "glyphive[pdf,zstd]"
glyphive create -f backup.pdf --compression zstd -C project .

Creation uses bounded-memory disk spools; --temp-dir selects their location and --chunk-size tunes sequential I/O for unusually constrained systems.

Restore scans or generated documents with Tesseract. Input type is detected from file contents first and the extension second:

pip install "glyphive[ocr,document-input]"
glyphive extract -f scans/ --ocr-engine tesseract -C restored
glyphive list -f backup.pdf --ocr-engine tesseract

Restore verifies global integrity before publishing staged files. Advanced resource controls include --temp-dir, --chunk-size, and --max-output-bytes on both extract and list. Transcript frames, compressed payload, decompressed archive, and staged files are disk-backed; Reed-Solomon correction retains only compact offsets and one codeword at a time.

The operating-system Tesseract executable and language data must also be installed. PDF input uses pypdfium2; Glyphive-generated DOCX transcripts are read directly with python-docx, without Microsoft Word or LibreOffice. See the create guide, restore guide, and OCR guide for details.

Format at a glance

The default base16c-crc16-rs format uses exactly 16 payload symbols, or 4 bits per printed character. Each data (L) or parity (P) line has a masked index and a full CRC-16 encoded in the same safe alphabet:

L<5 safe index chars> <up to 60 safe payload chars> #<4 safe CRC chars>

CRC-protected H header frames carry the codec, compression method, page count, and whole-document SHA-256. Each page has a protected T footer with its page number and a truncated page hash. Human-facing #!glyphive and PAGE n/total text is display-only; restore trusts the protected frames.

Small, scattered line errors become known erasures and can be repaired by the document-wide Reed-Solomon parity. A missing page is reported rather than guessed, and the document-wide RS may still recover it from the surviving pages when the budget allows. create --parity-pages K (default 0, off) opts into a separate, guaranteed layer: K extra pages of document-level parity that survive up to K wholly lost pages regardless of the per-line budget. Read the wire-format guide for the complete layering and framing rules.

Standalone zipapp

Releases may include a self-contained glyphive.pyz. Build the universal core artifact with:

python package.py --out dist/glyphive.pyz
python dist/glyphive.pyz --help

The universal zipapp includes text output with none and gzip compression. Optional, platform-specific artifacts can be built with --extras; use python package.py --help for the declared choices.

API overview

Module Purpose
glyphive.archive Serialize and inspect deterministic archive streams, including chunked reader/writer primitives
glyphive.codec Resolve printable codecs; includes base16c-crc16-rs
glyphive.compression Resolve none, gzip, and optional zstd compression
glyphive.layout Paginate frames and verify protected page metadata
glyphive.plugins Explicitly discover trusted installed entry points
glyphive.render Render pages as text, PDF, or Word
glyphive.restore Decode documents and safely restore file trees
glyphive.restore.ocr Select OCR providers and OCR page images

Full generated API documentation is available on the documentation site.

Development

See CONTRIBUTING.md for setup, test, documentation, and pull request guidance.

Use a project-local virtual environment, then run the lightweight suite:

python -m venv .venv/dev
.venv/dev/Scripts/python -m pip install -e ".[all,dev,docs]"
.venv/dev/Scripts/python -m pytest -q
.venv/dev/Scripts/python -m mkdocs build --strict

On POSIX, replace .venv/dev/Scripts/python with .venv/dev/bin/python. OCR sweeps and performance measurements are separate manual workloads; see Benchmarks.

Releasing

Glyphive follows Semantic Versioning and keeps a CHANGELOG.md. Pushing a v* tag runs the release validation, package build, publication, and documentation deployment workflow.

License

MIT — see LICENSE.

The bundled OCR-B font retains its SIL Open Font License 1.1; see third-party licenses.

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

glyphive-0.1.0.tar.gz (717.0 kB view details)

Uploaded Source

Built Distribution

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

glyphive-0.1.0-py3-none-any.whl (341.5 kB view details)

Uploaded Python 3

File details

Details for the file glyphive-0.1.0.tar.gz.

File metadata

  • Download URL: glyphive-0.1.0.tar.gz
  • Upload date:
  • Size: 717.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for glyphive-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8278c011cc823b7112a804bcc99cfad94b686f45cedcd2b9e79de83ea808d8cd
MD5 bdf2e0b0f30faf1c8c39aff81a2282d2
BLAKE2b-256 14904ce0927a4f141f3097b6192d012d73046265f29eae344bd7455b0adf38b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for glyphive-0.1.0.tar.gz:

Publisher: release.yml on jose-pr/glyphive

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

File details

Details for the file glyphive-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: glyphive-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 341.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for glyphive-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f02cb893cccea52bc61386d315d7a0db0ecc5bc3952d0c67049b41f4146747c
MD5 3bb0971fe8890235e6fac3ed3d60db15
BLAKE2b-256 9050087a8a3c7c4c44fa74f2c2c676a5d37775edd606c52748ec1c2ab6117d27

See more details on using hashes here.

Provenance

The following attestation bundles were made for glyphive-0.1.0-py3-none-any.whl:

Publisher: release.yml on jose-pr/glyphive

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