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.0.tar.gz
(23.2 kB
view hashes)
Built Distributions
Close
Hashes for imagetext_py-1.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d300be266f5a46c4ad31e88aafc2827bbb583502c1a036001085d842e4c26d2f |
|
MD5 | 2af4555715a60d3a4a30cfaefc9822be |
|
BLAKE2b-256 | 3217c5fb9c5d92c40f9349b8dfca70d323a856e2bb62eade0d160847cfd912f8 |
Close
Hashes for imagetext_py-1.0.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d955675c04638ce22b89788d01ca4953c9c85a2592ce5d3b8ee516d71464ad11 |
|
MD5 | 5047f4853ca521858df8db51cde20553 |
|
BLAKE2b-256 | c8531ca05ae2e072fcde03ee717dcdd4dbdd8c5e2c8aa0c86aaca5b286a6c5e2 |
Close
Hashes for imagetext_py-1.0.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21548281d47072b872a5dc3d0d32684ea14efe6812e45194466b3333223d26d3 |
|
MD5 | 5550fa8247885bb5bce1eaf27b21c971 |
|
BLAKE2b-256 | 0f68e0be7427310a66ea90af94db4d868ec6d737984350ded693511925c13bf0 |
Close
Hashes for imagetext_py-1.0.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 093da875e2379be4993f424e086175c343e5921246fc3e6ac2b2ffd06a4f6145 |
|
MD5 | b0b61083c11a26b7035db10978ebacad |
|
BLAKE2b-256 | 31ad250762ef1770cb4b998faade587b768682393e068611c0ef310bafc2d095 |
Close
Hashes for imagetext_py-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c92f6cde0b083ec36cb67d15b9db8a78e0528cace2febf1e61b279b72dc25a5 |
|
MD5 | a7c9d6c49357257a0138f72d44c78921 |
|
BLAKE2b-256 | e40f470c77542d22df739f7c550435680ec669051e506b7198b461c53ee1dde2 |
Close
Hashes for imagetext_py-1.0.0-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ba351fb2074d25b6df8bcf1bcbd537b2f61135db51f4effccb2378c1b7ebc87 |
|
MD5 | e960f7ffa1325a47dedbc72ba1b40038 |
|
BLAKE2b-256 | 84eb6f378b01866d66c4c303c664f42c8d82ed05c74303dd7dce490f95d88080 |
Close
Hashes for imagetext_py-1.0.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bab839f97b116b020728813e80211d859fce336d09a9229fb48ea7defe71b5e3 |
|
MD5 | 18a791e62e311b0ddd0cbda50cc038bd |
|
BLAKE2b-256 | 09cc8c57e197c35bbee18080fbbe71bda4c81a54439d5366fd426a61ea4b4bff |
Close
Hashes for imagetext_py-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2b5ca830f46ba1a21d972b14ec4e7189f53ed55c36de31ea618fc0b7425ffa1 |
|
MD5 | 42afddfe1b4598f01254b8e740570905 |
|
BLAKE2b-256 | bb13cece98d0e5b19a574a306e9fa51759852da1f2d8df4aabb6b905753978fe |
Close
Hashes for imagetext_py-1.0.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17386ee7bf916db397d73e2fc86438b00d1eec060b532b81d34d8850c810c44a |
|
MD5 | 6fc3845e2a4314cb2a3efb4eb10d333b |
|
BLAKE2b-256 | 9fc414c1b78b240c78fe4b278f1beb0d41c186d010771ccc75b15305bb1fcc84 |
Close
Hashes for imagetext_py-1.0.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4348ee76770a7e312f1a7af86a6f2b9a4da1385b9ff5bc522fa649fa53c73317 |
|
MD5 | e4f8861219d348e6b4bc6fb192faf777 |
|
BLAKE2b-256 | 32c37e8e7fd043aa483f0c86e3da68d61961ef5837275b7addecbc7e4bef433b |
Close
Hashes for imagetext_py-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe22a3301c415fa4bfa2f4cb238f46d0d2c8dde9d7432f18e754ff8c79e7425 |
|
MD5 | ac5af9daa0e8d2ff35fba971157c48e6 |
|
BLAKE2b-256 | 54c8d05d07bc99be6e86e6796bb57bde17f798d4419056161d47128cad0166e8 |
Close
Hashes for imagetext_py-1.0.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5f5de57d21f237d5d9d8f5a041ece8b9bba61e0803b6c96ab07f392fa6079f8 |
|
MD5 | 7ca5c140b546678e0deeb0db3fcff4fe |
|
BLAKE2b-256 | 2ccf517e73ef7e14390c47efe9d64ba12a713cc4b1a35debc9e967af5eb88f94 |
Close
Hashes for imagetext_py-1.0.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ca9634f987ef8b507fdee204db4304df7c12ed0753dba142a8635cfb5be1043 |
|
MD5 | 0cd54030f25b3e6c49e3319848dcf66e |
|
BLAKE2b-256 | 512c629d0a511cb72e9ada3cd072f9361cc083156d17cc21995f53ebcfc8ab4a |
Close
Hashes for imagetext_py-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccfc551f48ec8144a0d9dbe49606b2fbeb82e787503c892aa3213194707bff4e |
|
MD5 | 3411520e12f3ddedcb83f0a46d3a7127 |
|
BLAKE2b-256 | 5da78ca822e9146b8c37d02d2a477459e3aada6c12bab90ef001050c7c5ae800 |
Close
Hashes for imagetext_py-1.0.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 961a1073a3b80a0703703f35708a22273b14801aa730dba718b69a4fc6ce19c5 |
|
MD5 | 2a2e41dcbf75633541f63ed8c02734f1 |
|
BLAKE2b-256 | d853c1be9c89fe27d0accca54a4ef503b8922fc1e098ff4eec35174e3a608d29 |
Close
Hashes for imagetext_py-1.0.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced4c945d74c55736f623a2bafaa45d6686339e66cef7a5c4e5e5c477341ba27 |
|
MD5 | a875bcf127a320219f9c8d923dd9b714 |
|
BLAKE2b-256 | d5381d6c83b86b193d5329f554d0af3e66759ddf26f77d351f2ff484df185f4c |
Close
Hashes for imagetext_py-1.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42718a74a3e95873b4e0ee74b255798b56ce0fbb893193a57046727879e5d08e |
|
MD5 | 5fdc453342c403c91afe97efdcd15add |
|
BLAKE2b-256 | 2ffbab4af13ec6866738feb3daedb6f4e6cabdb8a76c857dae7ec812850ab76d |
Close
Hashes for imagetext_py-1.0.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81b1c343b5a0d79b87510864200f17d57f09022625e231d8f5dabccf705994b3 |
|
MD5 | 754a5d55d4c83165bf6c2a13e9a7ba55 |
|
BLAKE2b-256 | d8c3974bdbe03226add89d9ab3acb08e3fb07e3e390a2c7f26832a88ce97789b |