Skip to main content

A tool for generating random images

Project description

Nazo Image Utils

Nazo Image Utils 是一个用于处理随机图像和图像处理的 Python 包。它包含两个类:RandImageProcessImage

安装

您可以使用 pip 安装 Nazo Image Utils:

pip install nazo-image-utils

ProcessImage

ProcessImage 是一个用于处理图像的类。

初始化

from nazo_image_utils import ProcessImage

process_image = ProcessImage(
    flush: bool = False,
    filter: bool = True,
    gallery_path: str = "./gallary",
    pc_filter_size: Size = PC_SIZE,
    mobile_filter_size: Size = MOBILE_SIZE,
)

gallery_path 为待处理图像的目录。

flushTrue 时,会忽视已生成的 json 文件中的内容。

filterTrue 时,会对图像进行过滤,只保留合格的图像。

默认情况下, pc 端的合格图像尺寸为 1920x1080,移动端的合格图像尺寸为 1080x1920。

初始化 ProcessImage 类的实例。

方法

try_process

process_image.try_process()

尝试处理所指定文件夹中的所有图片, 会分别存储到 webpjpeg 文件夹中。

默认情况下一个图片会分别生成三张图片, 分别为不同的分辨率的图片, 定为:source , th , md

还会生成两个文件分别为: manifest.jsonmanifest_mobile.json, 里面格式为:

{ "md5": { "source": "file_name" } }

RandImage

RandImage 是一个用于生成随机图像 URL 的类。

初始化

from nazo_image_utils import RandImage

rand_image = RandImage(pc_json_path="./manifest.json", mobile_json_path="./manifest_mobile.json", domain="https://example.com")

初始化 RandImage 类的实例。

方法

process

result = rand_image.process(
    ua: bytes,
    number: int,
    platform: Optional[bytes] = b"pc",
    encode: Optional[bytes] = b"",
    size: Optional[bytes] = b"source",
)

处理程序,生成随机图像的 URL。

参数
  • ua (bytes): 用户浏览器 user-agent 标识,用于检查 WebP 支持。
  • number (int): 请求的图像 URL 数量,范围为 1-10。
  • platform (bytes): 平台(决定竖图还是横图),传递 b"pc"b"mobile"
  • encode (bytes): 编码,仅传递 b"json" 或者不传。
  • size (bytes): 尺寸(仅决定返回的图片尺寸格式)。
返回值
  • byteslist[str]: 返回图像 URL 列表或 JSON 字符串。最终格式为: [domain]/[webp|jpeg]/[md5].{size}.[webp|jpeg],例如: https://nazo.run/webp/0a4d55a8d778e5022fab701977c5d840.source.webp

许可证

本项目采用 MIT 许可证进行许可 - 请参阅 LICENSE 文件获取更多详细信息。

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

nazo_image_utils-0.0.5.tar.gz (80.9 kB view details)

Uploaded Source

Built Distributions

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

nazo_image_utils-0.0.5-cp313-cp313-win_amd64.whl (110.6 kB view details)

Uploaded CPython 3.13Windows x86-64

nazo_image_utils-0.0.5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (289.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

nazo_image_utils-0.0.5-cp313-cp313-macosx_10_13_universal2.whl (144.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

nazo_image_utils-0.0.5-cp312-cp312-win_amd64.whl (110.9 kB view details)

Uploaded CPython 3.12Windows x86-64

nazo_image_utils-0.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (291.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

nazo_image_utils-0.0.5-cp312-cp312-macosx_10_13_universal2.whl (146.1 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

nazo_image_utils-0.0.5-cp311-cp311-win_amd64.whl (110.9 kB view details)

Uploaded CPython 3.11Windows x86-64

nazo_image_utils-0.0.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (283.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

nazo_image_utils-0.0.5-cp311-cp311-macosx_10_9_universal2.whl (146.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

nazo_image_utils-0.0.5-cp310-cp310-win_amd64.whl (110.8 kB view details)

Uploaded CPython 3.10Windows x86-64

nazo_image_utils-0.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (268.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

nazo_image_utils-0.0.5-cp310-cp310-macosx_10_9_universal2.whl (146.7 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

nazo_image_utils-0.0.5-cp39-cp39-win_amd64.whl (110.8 kB view details)

Uploaded CPython 3.9Windows x86-64

nazo_image_utils-0.0.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (268.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

nazo_image_utils-0.0.5-cp39-cp39-macosx_10_9_universal2.whl (147.2 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

nazo_image_utils-0.0.5-cp38-cp38-win_amd64.whl (110.9 kB view details)

Uploaded CPython 3.8Windows x86-64

nazo_image_utils-0.0.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

nazo_image_utils-0.0.5-cp38-cp38-macosx_11_0_universal2.whl (147.1 kB view details)

Uploaded CPython 3.8macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file nazo_image_utils-0.0.5.tar.gz.

File metadata

  • Download URL: nazo_image_utils-0.0.5.tar.gz
  • Upload date:
  • Size: 80.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for nazo_image_utils-0.0.5.tar.gz
Algorithm Hash digest
SHA256 642df9ba2d942360f4078d55fb08a9f340df9bc091b253fd8e657973592a62ac
MD5 117b4667e682b106b3788ded2ccebcff
BLAKE2b-256 0a01e3e4375042b3846fff7bc1e20c75aa94393e0cb7b0dcec7858391c181e5d

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0fa0d1caf3e7b227de28336bb27332fc57d815246fe32bc34ba42a9754d6776d
MD5 e1a3ccdbfeb5fd605f3fa7db37e3d736
BLAKE2b-256 cf0c798d243b06b527dc5a79a0f212a87954111ee6c489c825bf89a11de3c50f

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8f2a0324045acc105ffbb1a5bdc62ca8e7382b34ce0497512b6a6bee8edaf940
MD5 d1d180c78ffdc1b48aaef070cf99fe28
BLAKE2b-256 2def63c61ab3f12f0a44c2171923f2ee839d312ca37527d880ac77b75a7a5327

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 46c2cf5279696eaf4ae32a812262318b470f805e92b3dd0b0363f3ec37e1ae01
MD5 58b8db7f016e70fedc3e54f5c5aea0fb
BLAKE2b-256 cd9dda883bc50be14561bd5bc76db06b8ff75a17ff9e7b2291a398a0d288bd64

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 374a6005a788646a502bc01f440071496c21ab470f4c52955ab87a580791e245
MD5 7979ac7b3bf0a96517b1103532217cef
BLAKE2b-256 ab3c300e0b964d29325892697a44c58a0fbdbace57c1c0dde2916d750da488e2

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ceaf513ee46702526ca4b5e6baba62a1d6dee83a69320e39fce6b3c8ce4d50a1
MD5 d016ccd542cdd6123d9a918c4b88d88f
BLAKE2b-256 db1772e3776df4bf2e6cd48091ed84e846f853f88c3e0711046fc3934aecef98

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 c88f67ddece8aa4f84c85d226c54d55f60809c94c5393b3bb386fcec5b03f156
MD5 5f14aec1f5906c0dce6d56b7e2d416d4
BLAKE2b-256 5dcfebae2a87349194c3f8b944de0affec602f5c55ba1cf579e36958ffd63ff2

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1af6b1a53acbc2dacf7fdd8875d46235612727ea2f676a97949ae0f4514de01f
MD5 04079f66f74b4c0ce64910a6f02070af
BLAKE2b-256 5d68eef757ffadae2c564c976910e901e2dee7595cd0c7783893664a05e71839

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d9e74691a7794212e0a0f1d5f4bbdaf91dab59959b8a269b22947dd5741a890
MD5 6cc7c6023402c98d7df44df2d04fed99
BLAKE2b-256 d73d81297b65394fdf9ce8d8efb1d5b24adf09eb37c6355529445e76bb742221

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2510f7baefafd4c7388342baed8e0a0ee07d1e6901e0fb7d3553f9f837bd5579
MD5 aaf22e1251eb2815b0b246a91da470dc
BLAKE2b-256 80bbd0ddeac30ceab4b4d42914b6e3b1f285added173cfd9abf98a1cf9824a4e

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 752f824b56aea1aefd281f269b4ff61fb62019dcbda79e40fa56353c7892b72c
MD5 5a863f8ccd479b2acc3f1c6d3bb0c151
BLAKE2b-256 6a8324228e9aabd2aead372dd1d8eb53ed1f7234c194355ca16398f16be1f121

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd227aa435a32bfd88cc4d76ba7d7f93214f253934fa621d6e1e7e442c044995
MD5 e803f61759eff1cb76cd7ca5818a480e
BLAKE2b-256 d931c8d347ce57a03c0f5dcd1f944ceac81a04d9a4177f68b6d5f14da12de0a2

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4284d16aa47bbba3832e17423de0860940bad35325e356c502751fd4b0c3d080
MD5 56faf171da3530fd2a1ae75defbee6c2
BLAKE2b-256 564ff3c83843c9a02e14244d8b0eee330810e5d28c6c11d134df7978a2feb029

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 23b7953f334674bbc9a873fda75d1c46e85a581fcbf4c5e165f8b8a285ebe5cc
MD5 619b972cfa51b31a1379192f44c18c40
BLAKE2b-256 2047bbadd4613199a9cee4f831c7de0235eb8d4912d3c963bcf89f1c9c1b6029

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2f7f4335d6c4875d36f6f8d8cb4ee20e900ee51fc068574fe1d99185ccf2406
MD5 fea74d9dc6b1d69879ca864b8df770d1
BLAKE2b-256 05d3cf58e5101ad666f68dbf0e2c6f068f1f92328689c968b42b8aaaeb4eee8e

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 77b5c588f63a2ed7cfb1b9fc2c93bc8351a8bc36b55485b05193e434f2726cf2
MD5 93b7dffa45f3b0c23e24d820f0c6493f
BLAKE2b-256 9673d3f95986d6bd39dfba874560323a51f8dc354ab76c6a3b1760af831b5e5e

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 948c5a6dc4546b83b188e0f6ae2ce89a342b047378d6af3a2c33d4bc4485b6b1
MD5 82feb39b13180ef8369655692b8bec49
BLAKE2b-256 242af890c4e6b0a51f55d31cb279c4b2c8235795cc046b180b3bc3d9036243d6

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 608505ddbd3ded84a2404a94341ce8ac3790f1215080ae49e691a80fac6eb300
MD5 ad3de6f0f613fc3029256158f7c21c8f
BLAKE2b-256 48ea5e81a267d6206415d36883daaec1a3abe021a3a42cd67ff60950bfc06210

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.5-cp38-cp38-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.5-cp38-cp38-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 bd698184ccd2cbcaf3338b8e2549ab8f01882af281d4e3e3f21c7f5409b7f3b4
MD5 5445d0de95d95d67a03c3fc6398c4a7b
BLAKE2b-256 7103b5a4cc77d92a05a5565ca7a322ce289a6ef406a331f49a60c0902910d7e5

See more details on using hashes here.

Supported by

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