A simple PIL wrapper and text-to-image tool
Project description
pil-utils
功能
- 提供
BuildImage
类,方便图片尺寸修改、添加文字等操作 - 提供
Text2Image
类,方便实现文字转图,支持少量BBCode
标签
使用示例
BuildImage
from pil_utils import BuildImage
# output: BytesIO
output = BuildImage.new("RGBA", (200, 200), "grey").circle().draw_text((0, 0, 200, 200), "测试test😂").save_png()
Text2Image
from pil_utils import Text2Image
# img: PIL.Image.Image
img = Text2Image.from_text("@mnixry 🤗", 50).to_image(bg_color="white")
- 使用
BBCode
from pil_utils import text2image
# img: PIL.Image.Image
img = text2image("N[size=40][color=red]O[/color][/size]neBo[size=40][color=blue]T[/color][/size]\n[align=center]太强啦[/align]")
目前支持的 BBCode
标签:
[align=left|right|center][/align]
: 文字对齐方式[color=#66CCFF|red|black][/color]
: 字体颜色[stroke=#66CCFF|red|black][/stroke]
: 描边颜色[font=Microsoft YaHei][/font]
: 文字字体[size=30][/size]
: 文字大小[b][/b]
: 文字加粗[i][/i]
: 文字斜体[u][/u]
: 文字下划线[del][/del]
: 文字删除线
特别感谢
- HibiKier/zhenxun_bot 基于 Nonebot2 开发,非常可爱的绪山真寻bot
- kyamagu/skia-python Python binding to Skia Graphics Library
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
pil_utils-0.2.0b3.tar.gz
(12.6 kB
view details)
Built Distribution
File details
Details for the file pil_utils-0.2.0b3.tar.gz
.
File metadata
- Download URL: pil_utils-0.2.0b3.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.0 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 826c030cc9a90de6d98c7fdb28eabbfb30533c8af4c580d36cbf1c803152c2e2 |
|
MD5 | 34ccf3376c387da9f492fefb503fc487 |
|
BLAKE2b-256 | a8f59e16d9de4414b3413bce7d995c3e487cad17882d5d5b80b85d676ae0a719 |
File details
Details for the file pil_utils-0.2.0b3-py3-none-any.whl
.
File metadata
- Download URL: pil_utils-0.2.0b3-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.0 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a10b6eb378e2cc69f0f3389362c9845bbc8a46729c4598d64ad2aa6571ef35a |
|
MD5 | 86e320bc0b0fb2bb3a1755dc1bba930f |
|
BLAKE2b-256 | b85978b5438e2f87c55d600ad6bfb37dad19909b975f53e2013fc94d11ef2fc2 |