Skip to main content

Finds the best fitting text size for a bounding box

# Tested with:
# Python 3.9.13
# Windows 10

pip install cv2-fit-text-in-box

from cv2_fit_text_in_box import fit_text_in_box
text = """Eins, zwei, drei, vier, fünf, 
sechs, sieben, acht, neun, aus!
Alle warten auf das Licht.
Fürchtet euch, fürchtet euch nicht!
Die Sonne scheint mir aus den Augen,
sie wird heut Nacht nicht untergehen,
und die Welt zählt laut bis zehn.
Eins, hier kommt die Sonne.
Zwei, hier kommt die Sonne.
Drei, sie ist der hellste Stern von allen.
Vier, hier kommt die Sonne.
Die Sonne scheint mir aus den Händen,
kann verbrennen, kann euch blenden,
wenn sie aus den Fäusten bricht,
legt sich heiß auf dein Gesicht,
legt sich schmerzend auf die Brust,
das Gleichgewicht wird zum Verlust,
lässt dich hart zu Boden gehen,
und die Welt zählt laut bis zehn.
Eins, hier kommt die Sonne.
Zwei, hier kommt die Sonne.
Drei, sie ist der hellste Stern von allen,
vier, und wird nie vom Himmel fallen.
Fünf, hier kommt die Sonne.
Sechs, hier kommt die Sonne.
Sieben, sie ist der hellste Stern von allen.
Acht, neun, hier kommt die Sonne.
"""

fertig = fit_text_in_box(
    text,
    textcolor=[(255, 255, 0), (0, 0, 0)],
    backgroundcolor=[(0, 0, 150), (0, 110, 0)],
    transparent=True,
    filepath="f:\\testpicture1.png",
    maximalx=1280,
    maximaly=420,
    columns=2,
    fontart="arial.ttf",
    fontborder=2,
    distance_upper_left=(1, 1),
)
fertig = fit_text_in_box(
    text,
    textcolor=[(255, 0, 0)],
    backgroundcolor=[(50, 50, 0), (30, 30, 0), (10, 0, 0)],
    transparent=False,
    filepath="f:\\testpicture3.png",
    maximalx=720,
    maximaly=720,
    columns=1,
    fontart="arial.ttf",
    fontborder=2,
    distance_upper_left=(1, 1),
)
fertig = fit_text_in_box(
    text,
    textcolor=[(255, 255, 0)],
    backgroundcolor=[(0, 0, 150), (0, 0, 0)],
    transparent=True,
    filepath="f:\\testpicture4.png",
    maximalx=1280,
    maximaly=720,
    columns=3,
    fontart="arial.ttf",
    fontborder=2,
    distance_upper_left=(1, 1),
)

Metadata

Release files for cv2-fit-text-in-box 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 cv2-fit-text-in-box 0.10
File Size Uploaded Provenance Actions
cv2_fit_text_in_box-0.10.tar.gz 5.6 kB Without provenance Details for cv2_fit_text_in_box-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cv2-fit-text-in-box 0.10
File Interpreter ABI Platform Actions
cv2_fit_text_in_box-0.10-py3-none-any.whl Python 3 none any Details for cv2_fit_text_in_box-0.10-py3-none-any.whl

Total release size: 12.9 kB

Release files / cv2_fit_text_in_box-0.10.tar.gz

Download URL cv2_fit_text_in_box-0.10.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
16fda7e56f2dfd9e17faf528d8fc8a3c225d05294f39bbbb12ab5ce58e6a7702
BLAKE2b-256 checksum
How to use checksums
d5ef5761980d328af3994a56a6e07c7c13aea612613a612e77ba52c25bdfa90c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

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

Download URL cv2_fit_text_in_box-0.10-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4208080834364542759f15f308c3ac8af81ce2795108a85cac052251a68e6f1a
BLAKE2b-256 checksum
How to use checksums
a281537084a60f5a275e64f1f814b3fe8d09f5365274e8956d193698aa6abe95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for cv2-fit-text-in-box 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