Skip to main content

pixlib 图像处理工具包

PyPI version Python License Documentation Status

一个轻量级的 Python 图像处理库,专为 AI 图像生成工作流设计。提供纯色图检测、图片有效性校验、透明区域检测、URL 图片下载、MD5 计算、通用 HTTP 请求客户端等实用功能。

主要特性

  • 纯色图检测 (ImageTool.is_plain_gray) - 通过 7 个维度综合判定图片是否为纯色图,支持 bytes / 文件路径 / URL 输入
  • 图片有效性校验 (ImageTool.is_valid_image) - 检测图片是否损坏或不完整,支持 bytes / 文件路径 / URL 输入
  • 透明区域检测 (ImageTool.has_multiple_transparency) - 检测图片是否包含多个透明区域,支持 bytes / 文件路径 / BytesIO / URL 输入
  • 批量透明区域检测 (ImageTool.batch_has_multiple_transparency) - 多线程 + tqdm 进度条批量检测目录下所有图片的透明区域
  • 透明/白色边缘裁剪 (ImageTool.trim_transparent_edges) - 自动裁剪图片的透明/白色边缘并可选添加 padding,支持 bytes / 文件路径 / BytesIO / URL 输入
  • 彩色线条检测 (ImageTool.has_colored_lines) - 检测黑色背景上是否仅包含绿色/红色线条,五重过滤(面积占比 + 颜色纯度 + 双色占比 + 稀疏豁免 + 通道比值)排除填充图/多色图/单色文字/干扰色,支持抗锯齿暗绿色识别,支持 bytes / 文件路径 / BytesIO / URL 输入
  • URL 图片下载 (ImageTool.get_img_url_io) - 从 URL 获取图片,支持指数退避重试
  • MD5 计算 (utils.str_to_md5) - 支持字符串、bytes、文件路径
  • 随机字符串 (utils.generate_random_lowercase) - 生成指定长度的随机小写字母
  • HTTP 请求客户端 (HttpRequestClient) - 通用HTTP客户端,支持指数退避重试、GET/POST快捷方法,内置断开ConnectionError重链。

安装

pip install pixlib

使用示例

import pixlib

# 纯色图检测(支持 bytes / 文件路径 / URL)
is_gray, metrics, msg = pixlib.ImageTool.is_plain_gray(image_bytes)
is_gray, metrics, msg = pixlib.ImageTool.is_plain_gray("/path/to/image.png")
is_gray, metrics, msg = pixlib.ImageTool.is_plain_gray("https://example.com/img.png")

# 图片有效性校验(支持 bytes / 文件路径 / URL)
try:
    pixlib.ImageTool.is_valid_image(image_bytes, task_id="abc123")
except Exception as e:
    print(e.extra_data)

# 透明区域检测(支持 bytes / 文件路径 / BytesIO / URL)
has_transparent = pixlib.ImageTool.has_multiple_transparency(image_bytes)

# 批量透明区域检测(多线程 + tqdm 进度条)
results = pixlib.ImageTool.batch_has_multiple_transparency("./images", max_workers=8)
for path, has_trans in results.items():
    if has_trans:
        print(f"有透明区域: {path}")

# 裁剪透明/白色边缘(支持 bytes / 文件路径 / BytesIO / URL)
cropped_bytes = pixlib.ImageTool.trim_transparent_edges(image_bytes, padding=10)
cropped_bytes = pixlib.ImageTool.trim_transparent_edges("/path/to/image.png", padding=20, output_format="WEBP")

# 彩色线条检测(检测黑色背景上的绿色/红色线条)
result = pixlib.ImageTool.has_colored_lines("images/lines.jpg")
print(result)
# {'has_lines': True, 'has_green': True, 'has_red': True, 'green_ratio': 0.5076, 'red_ratio': 0.4819, ...}

# URL 下载图片
im_io = pixlib.ImageTool.get_img_url_io("https://example.com/img.png")

# MD5 计算
pixlib.utils.str_to_md5("hello")
pixlib.utils.str_to_md5("/path/to/image.png")

# 随机字符串
pixlib.utils.generate_random_lowercase(10)

# HTTP 请求客户端
client = pixlib.HttpRequestClient(max_retries=3, base_timeout=300)
resp = client.get("https://example.com/api/data")
resp = client.post("https://example.com/api/submit", json={"key": "value"})

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 Distributions

If you're not sure about the file name format, learn more about wheel file names.

pixlib-1.0.6-cp314-cp314-win_amd64.whl (151.6 kB view details)

Uploaded CPython 3.14Windows x86-64

pixlib-1.0.6-cp314-cp314-manylinux_2_17_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

pixlib-1.0.6-cp313-cp313-win_amd64.whl (149.3 kB view details)

Uploaded CPython 3.13Windows x86-64

pixlib-1.0.6-cp313-cp313-manylinux_2_17_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pixlib-1.0.6-cp312-cp312-win_amd64.whl (150.5 kB view details)

Uploaded CPython 3.12Windows x86-64

pixlib-1.0.6-cp312-cp312-manylinux_2_17_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pixlib-1.0.6-cp311-cp311-win_amd64.whl (153.5 kB view details)

Uploaded CPython 3.11Windows x86-64

pixlib-1.0.6-cp311-cp311-manylinux_2_17_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pixlib-1.0.6-cp310-cp310-win_amd64.whl (154.4 kB view details)

Uploaded CPython 3.10Windows x86-64

pixlib-1.0.6-cp310-cp310-manylinux_2_17_x86_64.whl (994.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pixlib-1.0.6-cp39-cp39-win_amd64.whl (155.3 kB view details)

Uploaded CPython 3.9Windows x86-64

pixlib-1.0.6-cp39-cp39-manylinux_2_17_x86_64.whl (991.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pixlib-1.0.6-cp38-cp38-win_amd64.whl (159.0 kB view details)

Uploaded CPython 3.8Windows x86-64

pixlib-1.0.6-cp38-cp38-manylinux_2_17_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file pixlib-1.0.6-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 151.6 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ec4358d7076cb6c05244c8f78615a2fb8433dd5cbf7abae085f4b22aa2dbd627
MD5 e45a30224c36fcbe698116dcb0c21309
BLAKE2b-256 f083c5c96f883e0db460a661ebc500865199edc10875a4b206e4d2b5bf728f37

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp314-cp314-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp314-cp314-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp314-cp314-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d76fe667622da2ecb972a69c6ff46b9342c0969c7522642034d65315b35bb207
MD5 817acc9eeb4e5ea4152fa08ab7ec588f
BLAKE2b-256 e72c7f5b4627df977855befce13a145269ba15694c2596bd1e0a6ec273b75a0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp314-cp314-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 149.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f34a9a60c1aaab0020e740ab4adbada5a5b87255705dac3247de93a224277117
MD5 d770e50f110e1abf73a2f1e00e358113
BLAKE2b-256 d61292ed443357b6393b97f293337754b82f4b99029b4efbb08ecb7b3f56d7c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp313-cp313-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 e212f25e7c3c4485bb9177511303dbd347d4527178c78a99d9489ea3ac1fc14d
MD5 6a3c059c3f64206e713aec11543cdf78
BLAKE2b-256 e884da83f57555511963563b65aa79ac721fcccb85a548fc3fda802748a53377

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp313-cp313-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 150.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e711a00931bf07437d468f6ecb01392c7b223461bb938ac8862d1ad2b9824fca
MD5 011bdb7f19e17a76bea74924cb767608
BLAKE2b-256 70c73458df23e3ca19ead64089de266232700cbb1769655891c473511f5d0edc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp312-cp312-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 f8c3ed0fa10fe1e3c62e1673148aa63170ca26b8d03547b7f7e1711084f778e1
MD5 d9f096cbbe5105e653e0e81e4d2361d4
BLAKE2b-256 ea14f0c6997dd6e9785ead266e2b0c98fb22bce271df814f1d14570b9611023b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp312-cp312-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 153.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2f3870ca662244b8c9fc7fe74fa512368ea9e791800d7d85f1dfae024ed23ce9
MD5 f5423bb705018043c9050ec3971229bd
BLAKE2b-256 e7428e1b44a9bd730c05af6a1a5bdff2eebfd90ba21f8f6b0700d2d09ba84369

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp311-cp311-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0cc1d875b6066f821551241fa302c9a2538a609998275ae051cd37ea170fad2f
MD5 ec2ce9afa368b90106a0ab48e4b3f861
BLAKE2b-256 2f89b8c91829731155825cc8b24bdeb810ff0d719b264d66a713f21da45614c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp311-cp311-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 154.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 26c84fed76ec4da1b46af9da3cd9c59ba48ef2a5b199f9ad5622469cc7375c4d
MD5 2692ab0d245281b85252355bc6a35665
BLAKE2b-256 a6813b7e23f44c24f1c8af0e3e391ff0ed814d6f6fab366df6e42d43cc69c282

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp310-cp310-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 cdcef36ba5cd685f1f723627249ba1d60b5214a4f25f9763c4bbb75716da39a4
MD5 9c38396be834f75d53c5819c605b6903
BLAKE2b-256 4aa11280be5a75cdbc65cbcad34bc24860e79002ee10bb2c6d2edf93b5df1c6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp310-cp310-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 155.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bad711883db28980fc91cee13b48929a00fa34936f4450e5663b7d34c4df58dd
MD5 e3c09c59c2eacc8703613358f105ff33
BLAKE2b-256 379611270437e1182af45470feeb0f93ebdbf9d9795cd70d4dc47c3493cedbdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp39-cp39-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp39-cp39-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 06cf05f6470640327fe7304b5dc9fab5a53c914cdd6b97292db02622ffec575d
MD5 34cea3b00143c3c152117b77929e49fb
BLAKE2b-256 557b98a2bdde580dddfe765e1eeb4b9bbbcdf6c1428f5746625ede10d7e2479e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp39-cp39-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pixlib-1.0.6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 159.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixlib-1.0.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c9f270fb15adae8f268843b9f9bc40057e11f1b95dad20476234192bbb1dd894
MD5 b0db3cca66880c90508fdda1342ec858
BLAKE2b-256 a32c1e915021fb54b3797cb2386eadff678dd63d23a9c18676c3cf9cbb2b7f1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp38-cp38-win_amd64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixlib-1.0.6-cp38-cp38-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pixlib-1.0.6-cp38-cp38-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 31f071f56f72273e31f82ecb1f8deb5a567db881e0fdeb3093c6c4e40cc50a19
MD5 43d617860fba7dfeca4f8931fea09d49
BLAKE2b-256 40b0cc2a04cd15aa991b9db83127583ab40677cff8393139d8f7533acb8a4d74

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixlib-1.0.6-cp38-cp38-manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on zhenzi0322-package/pixlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.7

14 files

This release

1.0.6 This release

14 files

1.0.5

14 files

1.0.4

14 files

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