About
imagetext makes use of rusttype for font parsing and tiny-skia for drawing. It has a simple API that allows you to draw text with ease.
Features
- Multi-line text
- Text wrapping
- Text alignment
- Font fallbacks
- Text stroke
- Gradient fills
- Emojis! (almost every platform supported)
- Global Font Database with css-like font querying
Installation
pip install imagetext-py
Example Usage
from PIL import Image
from imagetext_py import *
# supports fonts with fallbacks
font = Font("coolvetica.ttf", fallbacks=["emojis.ttf", "japanese.otf"])
# create a canvas to draw on
cv = Canvas(512, 512, (255, 255, 255, 255))
# paints are used to fill and stroke text
black = Paint.Color((0, 0, 0, 255))
rainbow = Paint.Rainbow((0.0,0.0), (256.0,256.0))
# if a font doesn't have a glyph for a character, it will use the fallbacks
text = "hello my 😓 n🐢ame i☕s 会のすべ aての構成員 nathan and i drink soup boop coop, the quick brown fox jumps over the lazy dog"
draw_text_wrapped(canvas=cv, # the canvas to draw on
text=text,
x=256, y=256, # the position of the text
ax=0.5, ay=0.5, # the anchor of the text
size=67, # the size of the text
width=500, # the width of the text
font=font,
fill=black,
align=TextAlign.Center,
stroke=2.0, # the stroke width (optional)
stroke_color=rainbow) # the stroke color (optional)
# you can convert the canvas to a PIL image
im: Image.Image = cv.to_image()
im.save("test.png")
# or you can just get the raw bytes
dimensions, bytes = cv.to_bytes()
# you can also save directly to a file
cv.save("test.png")
produces this image:
took 6ms to draw this on my machine
Pillow and FontDB Usage
from PIL import Image
from imagetext_py import *
FontDB.SetDefaultEmojiOptions(EmojiOptions(allow_discord=True))
FontDB.LoadFromDir(".")
font = FontDB.Query("coolvetica japanese")
with Image.new("RGBA", (512, 512), "white") as im:
with Writer(im) as w:
w.draw_text_wrapped(
text="hello from python 😓 lol, <:blobpain:739614945045643447> " \
"ほまみ <:chad:682819256173461522><:bigbrain:744344773229543495> " \
"emojis workin",
x=256, y=256,
ax=0.5, ay=0.5,
width=512,
size=90,
font=font,
fill=Paint.Color((0, 0, 0, 255)),
align=TextAlign.Center,
stroke=2.0,
stroke_color=Paint.Rainbow((0.0,0.0), (256.0,256.0)),
draw_emojis=True
)
im.save("test.png")
Metadata
Release files for imagetext-py 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 64.4 MB
Release files / imagetext_py-2.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | imagetext_py-2.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
1c370b06c1a84ed9f28bc939c401269097266802437cd344b10dd8fca152921f
|
|
BLAKE2b-256 checksum How to use checksums |
b5b4def635e818b1e78a28201f22c0addfe4fe57c712f08ce59dc5f3618e7236
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp311-none-win_amd64.whl
| Download URL | imagetext_py-2.0.1-cp311-none-win_amd64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
286da2ed58ff2717798fda97aa15c1bf3bf390c1244675a39f407b30f82e431f
|
|
BLAKE2b-256 checksum How to use checksums |
303560e02111ccc29a8a1600257d94d570df7829911d3c56d9b01f669ff3f72e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | imagetext_py-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b4d1437c32d60c5ab36db8c31c04b3b2fddd7c34086147adfac787c30cc9c7f8
|
|
BLAKE2b-256 checksum How to use checksums |
d23d770906e5f914e2ffbee2239645402c9fac97fd459dfbdf5e3c12008cdf6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
| Download URL | imagetext_py-2.0.1-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
06774d4a1cd1865232e51456f784d259481e17522766fe22eb7fd77e16ca5717
|
|
BLAKE2b-256 checksum How to use checksums |
04ec2a606b2e96b1a22f68a73ce80d4057328ca255e7bdbb86f4b7841535eda7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp310-none-win_amd64.whl
| Download URL | imagetext_py-2.0.1-cp310-none-win_amd64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f1390275fb79caf016d2c9c687844fcb825ae152033c73897f5915a575676af6
|
|
BLAKE2b-256 checksum How to use checksums |
560609904578566de84b90d15805995b3da2f76d11aa8cc4432965f301cdfe69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | imagetext_py-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
44d812e0eaed64045b98973291f1afbef56f757351ecd328faac1b777ea03411
|
|
BLAKE2b-256 checksum How to use checksums |
29fa6ed42851bc4f7dce77bdb4605192166a57253263ad4d77bc1a0b940dfd46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
| Download URL | imagetext_py-2.0.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0324160d5ebac225fb33af17bcdbd81fa322f6d312c92d39a462cbfd85e289ca
|
|
BLAKE2b-256 checksum How to use checksums |
7dac8307ca9127f253d11e57267b7a25c044966e48d006296e480215db6ac6af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp39-none-win_amd64.whl
| Download URL | imagetext_py-2.0.1-cp39-none-win_amd64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
265b0df76ad86c3b924711f84b2bd1cdf8500d9fd19553830cbb69f701707194
|
|
BLAKE2b-256 checksum How to use checksums |
0f2a83bfc0423019deb370f8b454e219f442d6f71f2b5879dcb8e7f229c197df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | imagetext_py-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a485150f3e929e87725c80a2706e1d94457770d33cbf6720e275bfb074d532c0
|
|
BLAKE2b-256 checksum How to use checksums |
df61542b67c7949d6a7d42146c3d7c7e0a41c8cb51352384fcc2576189e42395
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Release files / imagetext_py-2.0.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
| Download URL | imagetext_py-2.0.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0c8321787bb9f137552d7f707c2a16c3e195f99de0f04e1bc74529b82b66e0b4
|
|
BLAKE2b-256 checksum How to use checksums |
a9f7b6d9002e44bb0891ee8b45d7f64bd1bfde08ce8e79f25b02433821b507a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.14.10
|
Security for imagetext-py 2.0.1
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.