Python bindings for imagetext
Project description
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
imagetext_py-1.0.1.tar.gz
(24.6 kB
view hashes)
Built Distributions
Close
Hashes for imagetext_py-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9da2c5cacc71508a040802e080e3b66f0c9ac72d4e423977c83daa1eaede5729 |
|
MD5 | 7a0c215a5af69b9df9df06847b62f4d0 |
|
BLAKE2b-256 | b4fc650b10d58bbe95704dfd22ce35ca6cae43195eb3dfd03d105b419f5ceb9c |
Close
Hashes for imagetext_py-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cde4f6b6e848c88d11618f6e13d5179e22426654cf25bd0ec92f9a46de14200 |
|
MD5 | 25cb1f96552269026ee1fc6a0bdcef29 |
|
BLAKE2b-256 | b0739f70ccab599c8afda4ed032c71a1d2228524691603142eb244f7015b0a8c |
Close
Hashes for imagetext_py-1.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b07c316f8662afcf4f16b23f6d68ccbaaabbd405a76caaeadba7218733baea19 |
|
MD5 | 22a30361ac11cc662097cf2186e37fd3 |
|
BLAKE2b-256 | a1cae3c82ccd862a8c431db26d9463126204f1f634005f9d5ce753f8f8d6be89 |
Close
Hashes for imagetext_py-1.0.1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f6f44bbcbc0e2d2311395e7ecb025e3143eb81402870a411265cc1a01f61741 |
|
MD5 | 514977a1a5188d5dc01c27a7ed4526a6 |
|
BLAKE2b-256 | 1c4e58f31d64d97a8e521b2e7a21e12b37661e684988f876b4a872ab7fe8361a |
Close
Hashes for imagetext_py-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e59a676d6babbf66ddceb3205d12b43c3fa25bfe9c0e426e3b35e04226e63b |
|
MD5 | 9d61108f2d1e7bd8dc84b6164bb89bd4 |
|
BLAKE2b-256 | c82937f2363776158abe16912213d6f03910cda2e46830114aac4f021741b33a |
Close
Hashes for imagetext_py-1.0.1-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7356d8266ff5db491b62473e678598b9f1cba00672ce25595a280aba3d0a02c |
|
MD5 | d8f17855734b5f7edd62d8ff310a417f |
|
BLAKE2b-256 | cefe80772247c89a2a7397098893b1d259a3d7780e328c38fc623018f13049c0 |
Close
Hashes for imagetext_py-1.0.1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aa2a7487b780cb4d17319c5bf52c6e7a317c6fcbfbceb7fd814ac39f5b4ff5d |
|
MD5 | 673a7e7dee80d13d7e8ec573edfb9950 |
|
BLAKE2b-256 | bb579a0843218c370a5b1fa2bf5ceffa6f9be6be81a3c2357a0a1f21798d8bfd |
Close
Hashes for imagetext_py-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 592c5302964cc5ec9c726d58121b0156ee8858af140bdca63632c1379db45032 |
|
MD5 | cf74a2a86f39f5d09dc76d45280b3fdd |
|
BLAKE2b-256 | f646d709d2abdac1ab688da992b7f8fbd4acca790a98a610ec0ec84e8966b708 |
Close
Hashes for imagetext_py-1.0.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0240a77bab256df87fc9a75588ba797ce380c12e8cf5e5b329862d1f13a770d6 |
|
MD5 | 4a40a161f3400f2d2a858a18e19bbf63 |
|
BLAKE2b-256 | 4c08bafddf51dbbb852033078467f445081ee147505bc550433cda7a09d5dccc |
Close
Hashes for imagetext_py-1.0.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e89088f80bc091807671f80e72fb1599d7f61804184d0a2a6542b6353a62dc49 |
|
MD5 | 12e6e8290d7be9197e72647bbd4b17e3 |
|
BLAKE2b-256 | 16af39c23f2291d8f768a13fb824e59a5873487403ffd29c45573aedec10c69d |
Close
Hashes for imagetext_py-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba5a1b2ab73d5614ec6c6aef749bd39c869b2ae73b3d454d3e422111e63dd138 |
|
MD5 | 31c0a7306abeaf285a89084bc25b61b6 |
|
BLAKE2b-256 | b2e3985d034292d1a8d64d760f95d1882500af5cb19e8e891c4e9691f5bcbe9b |
Close
Hashes for imagetext_py-1.0.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7684eec591464044bf8f0556fd558bffed4686527e891a047aee123f9272b8cf |
|
MD5 | 7767810d0677d170dd098a272bb9a881 |
|
BLAKE2b-256 | 2318e625a63c5e61a5a815839537982960b6bf1a0b67e621caa06a03183ba9e6 |
Close
Hashes for imagetext_py-1.0.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92758134565f57b3c0bedd84c6a573d2edf168659226ff339cd036424082b631 |
|
MD5 | 78b67ae2cac351f7a6654fc2e8a5deac |
|
BLAKE2b-256 | 16296ec873f57c8be995c91da967a92d0cf7d02a0739ebceec72b626faf17ceb |
Close
Hashes for imagetext_py-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18e1282d1e0432aa7cf5cf4f3f32aa036c96e3379cdbb75d7f941af472a052af |
|
MD5 | 4acec943ec6d2292462272e95abe408b |
|
BLAKE2b-256 | e49d45ad8cd5ae9131f205425c4659374e9713256770143efbc5abdb1ea2640f |
Close
Hashes for imagetext_py-1.0.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9034907c23efa75a5b630abc33813185c6c2d2e12615ea53ceb0b23ea902866e |
|
MD5 | 418af866c3bbab32439c79f102e5601c |
|
BLAKE2b-256 | 4cdd48bd624e288dbd2726e713a9ae89a8c252d61d8071a2dd3ab72746e06b98 |
Close
Hashes for imagetext_py-1.0.1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d3f9f7fa415277d141b47b731f3b588b92eaa377156394e4209c845f03b8278 |
|
MD5 | 70bf6ea77786bf9ae4f39268796c0845 |
|
BLAKE2b-256 | 2a6a222540c9bea4ad44af0cf819e41fc3ebd2fc1d16a304f235d0f3547850b9 |
Close
Hashes for imagetext_py-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 648163daa2fce150ed46baf8a42cdf98917e90fea43d728f2bfa17f6e15df453 |
|
MD5 | 695d7c94bb9d0f5b1d9c16a4421071c4 |
|
BLAKE2b-256 | 97daf6fa202d13f97bb12b8603365e99b26d0b7c370670db6590ed030683cdfb |
Close
Hashes for imagetext_py-1.0.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4809a6dae41f1f38dfc63b7653658b60dea51e37e56cd2a52e7139d216ee802c |
|
MD5 | 2dbbf6a01b55f6d0de47368f7cf77bfc |
|
BLAKE2b-256 | a9b3dffd9108650f9deb561a60e3d8374a6e7803171094819bf508f62aedbfc1 |