Nonebot2 PIL工具插件
Project description
nonebot-plugin-imageutils
功能
- 提供
BuildImage
类,方便图片尺寸修改、添加文字等操作 - 提供
Text2Image
类,方便实现文字转图,支持少量BBCode
标签 - 文字支持多种字体切换,能够支持
emoji
- 添加文字自动调节字体大小
安装
- 使用 nb-cli
nb plugin install nonebot_plugin_imageutils
- 使用 pip
pip install nonebot_plugin_imageutils
配置字体
本插件选择了一些不同系统上的字体,以支持更多的字符
对于 Ubuntu
系统,建议安装 fonts-noto
软件包 以支持中文字体和 emoji
默认备选字体列表可在 nonebot_plugin_imageutils/config.py
中查看
可在 .env
文件中添加相应的变量来自定义备选字体
字体文件需要在系统目录下,或放置于机器人运行目录下的 data/fonts/
文件夹中
其他插件可以通过 nonebot_plugin_imageutils/fonts.py
中的 add_font
函数往字体文件夹中添加字体
使用示例
BuildImage
from nonebot_plugin_imageutils import BuildImage
# output: BytesIO
output = BuildImage.new((300, 300)).circle().draw_text((30, 30, 270, 270), "测试ymddl😂").save_jpg()
Text2Image
from nonebot_plugin_imageutils import Text2Image
# img: PIL.Image.Image
img = Text2Image.from_text("@mnixry 🤗", 50).to_image()
- 使用
BBCode
from nonebot_plugin_imageutils import text2image
# img: PIL.Image.Image
img = text2image("N[size=40][color=red]o[/color][/size]neBo[size=30][color=blue]T[/color][/size]\n[align=center]太强啦[/align]")
特别感谢
- HibiKier/zhenxun_bot 基于 Nonebot2 和 go-cqhttp 开发,以 postgresql 作为数据库,非常可爱的绪山真寻bot
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
Built Distribution
Close
Hashes for nonebot_plugin_imageutils-0.1.4.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3ad30ebef6f2a5e97c918b3ad6a905ac9dac8e9c29231f3c4a0f9fc9999c8b |
|
MD5 | 796b6e0a3b1260b901ef0a2070d96841 |
|
BLAKE2b-256 | 2525e250b93494331da4723fbe2e186081ee73bacccf275072e3cc8342a48ae7 |
Close
Hashes for nonebot_plugin_imageutils-0.1.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2363e4db3b30312f5f1791ae8bbce4e8c0ad0b29b80246cc72981e5fd6b3e210 |
|
MD5 | 3ba0072c3c7a1967d0af51e31a98c05d |
|
BLAKE2b-256 | 44d379b9eb05873ba2d3cff4be001680e6c7a9235805a56bcdbec763acbbf2d1 |