Skip to main content

ci codecov PyPI version PyPI - Python Version Code style: black

aiopytesseract

A Python asyncio wrapper for Tesseract-OCR.

Installation

Install and update using pip:

pip install aiopytesseract

Usage

List all available languages by Tesseract installation

import aiopytesseract

await aiopytesseract.languages()
await aiopytesseract.get_languages()

Tesseract version

import aiopytesseract

await aiopytesseract.tesseract_version()
await aiopytesseract.get_tesseract_version()

Tesseract parameters

import aiopytesseract

await aiopytesseract.tesseract_parameters()

Confidence only info

import aiopytesseract

await aiopytesseract.confidence("tests/samples/file-sample_150kB.png")

Deskew info

import aiopytesseract

await aiopytesseract.deskew("tests/samples/file-sample_150kB.png")

Extract text from an image: locally or bytes

from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_string("tests/samples/file-sample_150kB.png")
await aiopytesseract.image_to_string(
	Path("tests/samples/file-sample_150kB.png").read_bytes(), dpi=220, lang='eng+por'
)

Box estimates

from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_boxes("tests/samples/file-sample_150kB.png")
await aiopytesseract.image_to_boxes(Path("tests/samples/file-sample_150kB.png")

Boxes, confidence and page numbers

from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_data("tests/samples/file-sample_150kB.png")
await aiopytesseract.image_to_data(Path("tests/samples/file-sample_150kB.png")

Information about orientation and script detection

from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_osd("tests/samples/file-sample_150kB.png")
await aiopytesseract.image_to_osd(Path("tests/samples/file-sample_150kB.png")

Generate a searchable PDF

from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_pdf("tests/samples/file-sample_150kB.png")
await aiopytesseract.image_to_pdf(Path("tests/samples/file-sample_150kB.png")

Generate HOCR output

from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_hocr("tests/samples/file-sample_150kB.png")
await aiopytesseract.image_to_hocr(Path("tests/samples/file-sample_150kB.png")

Multi ouput

from pathlib import Path

import aiopytesseract

async with aiopytesseract.run(
	Path('tests/samples/file-sample_150kB.png').read_bytes(),
	'output',
	'alto tsv txt'
) as resp:
	# will generate (output.xml, output.tsv and output.txt)
	print(resp)
	alto_file, tsv_file, txt_file = resp

Config variables

from pathlib import Path

import aiopytesseract

async with aiopytesseract.run(
	Path('tests/samples/text-with-chars-and-numbers.png').read_bytes(),
	'output',
	'alto tsv txt'
	config=[("tessedit_char_whitelist", "0123456789")]
) as resp:
	# will generate (output.xml, output.tsv and output.txt)
	print(resp)
	alto_file, tsv_file, txt_file = resp
from pathlib import Path

import aiopytesseract

await aiopytesseract.image_to_string(
	"tests/samples/text-with-chars-and-numbers.png",
	config=[("tessedit_char_whitelist", "0123456789")]
)

await aiopytesseract.image_to_string(
	Path("tests/samples/text-with-chars-and-numbers.png").read_bytes(),
	dpi=220,
	lang='eng+por',
	config=[("tessedit_char_whitelist", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")]
)

For more details on Tesseract best practices and the aiopytesseract, see the folder: docs.

Examples

If you want to test aiopytesseract easily, can you use some options like:

Docker / docker-compose

After clone this repo run the command below:

docker-compose up -d

streamlit app

For this option it's necessary first install aiopytesseract and streamlit, after execute:

# remote option:
streamlit run https://github.com/amenezes/aiopytesseract/blob/master/examples/streamlit/app.py
# local option:
streamlit run examples/streamlit/app.py

note: The streamlit example need python >= 3.13

Links

Metadata

Release files for aiopytesseract 1.1.0

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

Source distribution (sdist)

Source distribution for aiopytesseract 1.1.0
File Size Uploaded Provenance
aiopytesseract-1.1.0.tar.gz 16.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aiopytesseract 1.1.0
File Interpreter ABI Platform
aiopytesseract-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / aiopytesseract-1.1.0.tar.gz

Download URL aiopytesseract-1.1.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
639260f26b30357717cd8daaaa2a234a3492eee89db425fffdca4f61e33a3dfa
BLAKE2b-256 checksum
How to use checksums
36d76678ac784ddbaf319dbad46c68b0f0ec1b62fed1c0fc38dbb658c2b898c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / aiopytesseract-1.1.0-py3-none-any.whl

Download URL aiopytesseract-1.1.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb56227048943d5622c668eed2812dfa78040d29acdf431c5d4312dcf8abfaa3
BLAKE2b-256 checksum
How to use checksums
b172229f773418225c6eb94a00111c02272f6f274952589a95e54ad71552e1da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for aiopytesseract 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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