Skip to main content

No project description provided

Project description

基于pillow的简单文本转图片渲染工具

示例代码:

from easy_wrap import Drawer

text = "... the text you want to render ....测试自动换行"

font_path = "msyh.ttc"
font_size = 30
drawer = Drawer(font_path, font_size)

image_width = 180
canvas = drawer.draw_text(text, image_width)

# save the image
canvas.save(open("test.png", "wb")) 

特性:

  • 快速,800字平均渲染时长为0.03s(i7 cpu 2.7GHz)
  • 遵循如下换行规则(与css word-break: normal 稍有差异)
    • 纯中文:自动换行,一个汉字看做一个单词;
    • 纯英文:看做一个单词,不换行;
    • 遇到英文空格或者换行符:会换行;

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

easy_wrap-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file easy_wrap-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: easy_wrap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Windows/10

File hashes

Hashes for easy_wrap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53f2349304f27fa7da7831081960b2f140266446b7c17f6c112b409cf94e74bc
MD5 7e1f16f9c03d9b99f6f03f207f8618a9
BLAKE2b-256 3fa2d79e965c159e19b7dc08e78ca06ffba4df0c469f7f90d25859de1ab37eaf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page