基于 Playwright 的适用于 Graia 的文转图工具
Project description
GraiaX TextToImage (Playwright) 是一个基于 GraiaX Playwright 的文转图工具, 其可以将纯文本、Markdown 文本、HTML 代码通过 Playwright 转换为图片。
安装
pdm add graiax-text2img-playwright 或 poetry add graiax-text2img-playwright。
我们强烈建议使用包管理器或虚拟环境
开始使用
以下示例以 Ariadne 为例。
配合 Graia Saya 使用
from graiax.shortcut.saya import listen
from graiax.text2img.playwright import HTMLRenderer, convert_md, PageOption, ScreenshotOption
md = '''\
<div align="center">
# GraiaX TextToImage (Playwright)
*基于 Playwright 的适用于 Graia 的文转图工具*
</div>
GraiaX TextToImage (Playwright) 是一个基于 [GraiaX Playwright](https://github.com/GraiaCommunity/graiax-playwright) 的文转图工具,
其可以将纯文本、Markdown 文本、HTML 代码通过 Playwright 转换为图片。
## 安装
`pdm add graiax-text2img-playwright` 或 `poetry add graiax-text2img-playwright`。
> 我们强烈建议使用包管理器或虚拟环境
'''
@listen(FriendMessage)
async def function(app: Ariadne, friend: Friend):
image_bytes = await HTMLRenderer().render(
convert_md(md),
extra_page_option=PageOption(viewport={"width": 840, "height": 10}, device_scale_factor=1.5),
extra_screenshot_option=ScreenshotOption(type="jpeg", quality=80, scale="device"),
)
await app.send_message(friend, MessageChain(Image(data_bytes=image_bytes)))
预览
许可证
本项目使用 MIT 许可证进行许可。
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file graiax_text2img_playwright-0.5.0.tar.gz.
File metadata
- Download URL: graiax_text2img_playwright-0.5.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98cf673b25de664fdb5810c024472f427a90d7c37ff582f4ddfddc763455f259
|
|
| MD5 |
ddf898e6c153fa585c0f6703f3a80025
|
|
| BLAKE2b-256 |
89bf168e7220e06ea9950adb06ddb1d954108ac52a839cc0eea50a7bb8ec48e6
|
File details
Details for the file graiax_text2img_playwright-0.5.0-py3-none-any.whl.
File metadata
- Download URL: graiax_text2img_playwright-0.5.0-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6ec8f3e7ee8daf22f46bc3cd97b90ddfd1eb892fb1f6e42a3e581a951929e9b
|
|
| MD5 |
0dda9dce5b5ff42d7a74d77f3192243d
|
|
| BLAKE2b-256 |
fae8b893dabe7af7948705ca8b228260d4ec14288553ba106bbefa4eaf52485d
|