Skip to main content

Aligns text lines and characters within an image

Tested against Windows 10 / Python 3.11 / Anaconda

pip install wrilytextaligner

Original

Aligned

i (Any): The input image or file path.
blured_kernel (Tuple[int, int], optional): The kernel size for blurring the input image. Defaults to (5, 5).
blured_dst (int, optional): The destination for the blurred image. Defaults to 0.
adaptiveThreshold_max_value (int, optional): The maximum pixel value for the adaptive thresholding. Defaults to 255.
adaptiveTreshold_method (int, optional): The adaptive thresholding method. Defaults to cv2.ADAPTIVE_THRESH_GAUSSIAN_C.
adaptiveThreshold_block_size (int, optional): The block size for adaptive thresholding. Defaults to 11.
adaptiveThreshold_C (int, optional): The constant subtracted from the mean in adaptive thresholding. Defaults to 2.
rect_kernel_size (Tuple[int, int], optional): The kernel size for morphological operations. Defaults to (10, 10).
otsu_threshold (int, optional): The threshold value for Otsu's thresholding. Defaults to 0.
otsu_max_value (int, optional): The maximum pixel value for Otsu's thresholding. Defaults to 255.
max_line_join_distance (int, optional): The maximum distance for joining lines. Defaults to 30.
border_color_letters (Tuple[int, int, int], optional): The color of borders around characters. Defaults to (255, 255, 255).
letter_border_top (int, optional): The top border size for characters. Defaults to 10.
letter_border_bottom (int, optional): The bottom border size for characters. Defaults to 10.
letter_border_right (int, optional): The right border size for characters. Defaults to 10.
letter_border_left (int, optional): The left border size for characters. Defaults to 10.
line_border_top (int, optional): The top border size for lines. Defaults to 10.
line_border_bottom (int, optional): The bottom border size for lines. Defaults to 10.
line_border_right (int, optional): The right border size for lines. Defaults to 10.
line_border_left (int, optional): The left border size for lines. Defaults to 10.
image2crop (Union[None, np.ndarray], optional): An optional image to be cropped instead of the input image. Defaults to None.



import os, cv2
import numpy as np
from wrilytextaligner import align_wrily_text

outputfolder = r"C:\readx2"
if not os.path.exists(outputfolder):
	os.makedirs(outputfolder)
for ini, fi in enumerate(
	[r"https://github.com/hansalemaos/screenshots/raw/main/16_2.png"]
):
	allines = align_wrily_text(
		i=fi,
		blured_kernel=(5, 5),
		blured_dst=0,
		adaptiveThreshold_max_value=255,
		adaptiveTreshold_method=cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
		adaptiveThreshold_block_size=11,
		adaptiveThreshold_C=2,
		rect_kernel_size=(8, 8),
		otsu_threshold=0,
		otsu_max_value=255,
		max_line_join_distance=30,
		border_color_letters=(255, 255, 255),
		letter_border_top=10,
		letter_border_bottom=10,
		letter_border_right=10,
		letter_border_left=10,
		line_border_top=10,
		line_border_bottom=10,
		line_border_right=10,
		line_border_left=10,
		image2crop=None,
	)

	vstacked = np.vstack(allines)
	cv2.imwrite(rf"{outputfolder}\{ini}.png", vstacked)

Metadata

Release files for wrilytextaligner 0.10

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

Source distribution (sdist)

Source distribution for wrilytextaligner 0.10
File Size Uploaded Provenance Actions
wrilytextaligner-0.10.tar.gz 58.5 kB Without provenance Details for wrilytextaligner-0.10.tar.gz

Built distribution (wheel)

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

Total release size: 117.7 kB

Release files / wrilytextaligner-0.10.tar.gz

Download URL wrilytextaligner-0.10.tar.gz
Size 58.5 kB
Tags Source
SHA-256 checksum
How to use checksums
93df6c81430e26335730ee380f06dc27797f2888ef790311c819b2e442d3a808
BLAKE2b-256 checksum
How to use checksums
eefccc00c6e8adeabf208c737a5185f2eef9fa5976dd578b6ad3c47ef6da9749
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / wrilytextaligner-0.10-py3-none-any.whl

Download URL wrilytextaligner-0.10-py3-none-any.whl
Size 59.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fbf8097e668235309284f14870eb8333ebc33793779a3ef1e9561316eae989d
BLAKE2b-256 checksum
How to use checksums
2538d8bffe6f559fe00432917e5dfb32edd9792387cf11cf6e7ffebddc8e0a5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for wrilytextaligner 0.10

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.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

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