Skip to main content

GraiaX TextToImage (Playwright)

基于 Playwright 的适用于 Graia 的文转图工具

Code style: black Imports: isort License pdm-managed PyPI

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 许可证进行许可。

Metadata

Release files for graiax-text2img-playwright 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graiax-text2img-playwright 0.5.0
File Size Uploaded Provenance Actions
graiax_text2img_playwright-0.5.0.tar.gz 19.1 kB Without provenance Details for graiax_text2img_playwright-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graiax-text2img-playwright 0.5.0
File Interpreter ABI Platform Actions
graiax_text2img_playwright-0.5.0-py3-none-any.whl Python 3 none any Details for graiax_text2img_playwright-0.5.0-py3-none-any.whl

Total release size: 42.3 kB

Release files / graiax_text2img_playwright-0.5.0.tar.gz

Download URL graiax_text2img_playwright-0.5.0.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
98cf673b25de664fdb5810c024472f427a90d7c37ff582f4ddfddc763455f259
BLAKE2b-256 checksum
How to use checksums
89bf168e7220e06ea9950adb06ddb1d954108ac52a839cc0eea50a7bb8ec48e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / graiax_text2img_playwright-0.5.0-py3-none-any.whl

Download URL graiax_text2img_playwright-0.5.0-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6ec8f3e7ee8daf22f46bc3cd97b90ddfd1eb892fb1f6e42a3e581a951929e9b
BLAKE2b-256 checksum
How to use checksums
fae8b893dabe7af7948705ca8b228260d4ec14288553ba106bbefa4eaf52485d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for graiax-text2img-playwright 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page