Skip to main content

No project description provided

Project description

easy_wrap

基于pillow的简单文本转图片渲染工具,帮助实现自动换行

安装

pip install easy_wrap

需要Python3.8及以上环境

示例代码

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.04s(i7 cpu 2.7GHz)
  • 遵循如下换行规则(与css word-break: normal 稍有差异)
    • 纯中文:自动换行,一个汉字看做一个单词;
    • 纯英文:看做一个单词,不换行;
    • 遇到英文空格或者换行符:会换行;

更新日志

0.1.0

  • 第一个可用版本

0.1.1

  • 修复BUG:修复3.10以下python环境调用easy_wrap发生TypeError: 'type' object is not subscriptable的问题

0.1.2

  • 优化代码结构,完善注释

Project details


Download files

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

Source Distribution

easy_wrap-0.1.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

easy_wrap-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file easy_wrap-0.1.2.tar.gz.

File metadata

  • Download URL: easy_wrap-0.1.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • 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.2.tar.gz
Algorithm Hash digest
SHA256 31fee7b81935219d557fe33bd2367c2185e39d5384a1005086f6009e55c13145
MD5 f125e38ccb5b56a5ad353e0249683ec4
BLAKE2b-256 46d74b301ef1c3bf9db97d058962f183788d0bde5e7d4d8184c6e55ed32544d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easy_wrap-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc595c1d1c39cdc81f93d7258318c82fabbf36cb2f365dddb7684c3810efc06
MD5 7dcebafd921830676d7715e3bbd7aa64
BLAKE2b-256 57341db61aa6dac8c3b03b372a9a7e5a050c13e42b7f901dbcde63108c68c8ae

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