Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Refolio

Turn scans of bound books into clean, searchable PDFs — without changing a glyph.

日本語 · Beta · Guide: yoshida-kd.github.io/refolio

Refolio takes a PDF of a scanned or photocopied book — open as spreads, or page by page — and makes one that is easier to read: spreads split at the gutter, pages straightened and trimmed, page curl near the spine flattened, one standard paper size for the whole book with the text block at the same place on every page, the binding shadow and paper grain removed, and, optionally, an invisible text layer for search and copy.

It is a command-line tool (refolio) and a VS Code extension. Everything runs on your machine.

Principle

Refolio never draws a glyph. Every step either moves pixels geometrically (split, rotate, trim, flatten the curl, place on the paper; each step is recorded, so coordinates can be carried between the scan and the result) or multiplies them by a smooth brightness gain. Super-resolution is the only step that makes new pixels, and a super-resolved page is used only if every glyph keeps its shape (glyph_guard).

Install

pip install --pre refolio      # or: uv tool install --prerelease allow refolio (a beta)
refolio setup --sr             # super-resolution (Real-ESRGAN, 47 MB), used for scans below 300 dpi
refolio setup --ocr            # optional: the text layer (NDLOCR-Lite, about 0.5 GB)
refolio doctor                 # what is installed

Python 3.10 or later. PDFs are read with pypdfium2, so nothing else (poppler, Ghostscript) is needed. refolio setup --ocr needs uv: the text recognition lives in its own environment. Add --gpu to read on an NVIDIA GPU (onnxruntime-gpu with the CUDA and cuDNN libraries, about 2.4 GB).

Use

refolio make book.pdf book.refolio.pdf                 # the whole book
refolio make book.pdf out.pdf --size b5                # another paper size (auto by default)
refolio make book.pdf out.pdf --binding right          # right-bound books (vertical text): right page first
refolio make book.pdf out.pdf --layout off             # keep every scan as one page; only the brightness changes
refolio make book.pdf out.pdf --ocr off --sr off       # without the text layer or super-resolution

Text recognition and super-resolution are used when they are installed (--ocr auto, --sr auto). Super-resolution touches only grey pages scanned below 300 dpi.

Every command takes --json and then prints JSON Lines on stdout: progress lines, then one result or error. refolio docs prints a reference written for AI agents (Claude Code and others), so an agent can run Refolio for you.

Beta

  • Vertical text: give --binding right; it is not detected yet.
  • Overhead scanners (ScanSnap SV600 and the like) are not tested yet.
  • Text that was hidden in the fold when the book was scanned or copied cannot be recovered: press the book flat at the spine.

Credits and licenses

MIT License. Text recognition: NDLOCR-Lite (National Diet Library, Japan; CC BY 4.0). Third-party software: THIRD_PARTY_NOTICES.md.

Metadata

Release files for refolio 0.1.1b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for refolio 0.1.1b1
File Size Uploaded Provenance Actions
refolio-0.1.1b1.tar.gz 67.1 kB With provenance Details for refolio-0.1.1b1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for refolio 0.1.1b1
File Interpreter ABI Platform Actions
refolio-0.1.1b1-py3-none-any.whl Python 3 none any Details for refolio-0.1.1b1-py3-none-any.whl

Total release size: 131.4 kB

Release files / refolio-0.1.1b1.tar.gz

Download URL refolio-0.1.1b1.tar.gz
Size 67.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aaf48850ae19c9de673f2597ca5b9c9665e6c6bc743d7b22ccd8f2ec63e6f975
BLAKE2b-256 checksum
How to use checksums
437d0f0c5041b46f5b5d94b26ab7769e2422cc5caddf122e73dfe0c590145fbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / refolio-0.1.1b1-py3-none-any.whl

Download URL refolio-0.1.1b1-py3-none-any.whl
Size 64.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a05a5350d59fd0657bb7418e49885c8cddc04b6f8a4628a3e5538815bfd60473
BLAKE2b-256 checksum
How to use checksums
773ddbe13a511bc826c6cfaf321997de9313fb33e5fa8c7cff0f592c77bd8e36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Security for refolio 0.1.1b1

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.

Select from 2 files

Attestation for refolio-0.1.1b1.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 Nov 30, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page