Imgtoch
一个帮你将图片转为字符图片的模块。
用法:
# coding: utf-8
from imgtoch import makeImage
makeImage(
"源图片路径",
"生成的图片保存路径",
chars = None, # 用于图像的字符表,字符数应大于 1,无需手动按等效灰度值排序
scale = 1, # 缩放比例,0 < scale <= 1,可省略
quality = 80, # 图片保存质量,大于 0 小于等于 100
fontPath = "字体路径", # 可省略
fontSize = 14, # 字体大小,仅指定字体路径时生效,可省略
horzSep = 2, # 字符横向间隔,可省略
vertSep = 2, # 字符纵向间隔,可省略
keepRatio=True, # 是否保持原比例。因字体高宽不一定相等,生成的图片高宽会变形,此项为 True 则抵消变形,可省略
keepSize=False, # 一个字符对应一个像素点,因字符有大小,所以生成的图片尺寸会变化,此项为 True 会将生成的图片缩放至原图尺寸,可省略
)
实例 1:
# coding: utf-8
from imgtoch import makeImage
# 大图片尽量将 scale 设置的小些,否则生成的图片会比较大
# 字体大小 fontSize 也是影响最终生成的图片大小的因素之一
makeImage("1.jpg", "new.jpg", scale=0.2) # 图片 1.jpg 已在当前目录中
实例 2:
# coding: utf-8
from imgtoch import *
# 获取字符'#'的等效灰度值
print(grayscaleOf("#")) # ('#', 170)
# 将给定字符串按等效灰度值排序
print(sortByGrayscale("H oa.:sjv@%^a'"))
# 结果:['H', '@', 'a', '%', 'a', 's', 'j', 'o', 'v', '^', ':', "'", '.', ' ']
# 其中'a'和'%'的等效灰度值应该是相等的所以出现了'%'被夹在两个'a'中间的问题
# 更具体的参数可以看 IDE 提示或者使用 help 函数
Metadata
Release files for imgtoch 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imgtoch-0.2.3.tar.gz | 6.3 kB | Without provenance | Details for imgtoch-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imgtoch-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for imgtoch-0.2.3-py3-none-any.whl |
Total release size: 12.1 kB
Release files / imgtoch-0.2.3.tar.gz
| Download URL | imgtoch-0.2.3.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14672358336f66b381dd831d6b8410e4e398d1bf82af13f0356513f3f4bfbbed
|
|
BLAKE2b-256 checksum How to use checksums |
322430a8c056707747b8fc3b5690f8887bbfcced1069a8537da3bd0a8480224f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9
|
Release files / imgtoch-0.2.3-py3-none-any.whl
| Download URL | imgtoch-0.2.3-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f43db0ea03eced31417882f0c948f412a14729b57b042d3fb2279a465659b0e7
|
|
BLAKE2b-256 checksum How to use checksums |
196ece96dee99c98b6417d4c9d5309183bfeb5b1a5b7a80efd0b9c9824eb530d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9
|
Security for imgtoch 0.2.3
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.