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.4.tar.gz (80.8 kB view details)

Uploaded Source

Built Distributions

nazo_image_utils-0.0.4-cp312-cp312-win_amd64.whl (110.4 kB view details)

Uploaded CPython 3.12 Windows x86-64

nazo_image_utils-0.0.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (221.8 kB view details)

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

nazo_image_utils-0.0.4-cp312-cp312-macosx_10_9_universal2.whl (73.2 kB view details)

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

nazo_image_utils-0.0.4-cp311-cp311-win_amd64.whl (110.4 kB view details)

Uploaded CPython 3.11 Windows x86-64

nazo_image_utils-0.0.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (213.5 kB view details)

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

nazo_image_utils-0.0.4-cp311-cp311-macosx_10_9_universal2.whl (73.4 kB view details)

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

nazo_image_utils-0.0.4-cp310-cp310-win_amd64.whl (110.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

nazo_image_utils-0.0.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (197.7 kB view details)

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

nazo_image_utils-0.0.4-cp310-cp310-macosx_11_0_x86_64.whl (41.8 kB view details)

Uploaded CPython 3.10 macOS 11.0+ x86-64

nazo_image_utils-0.0.4-cp39-cp39-win_amd64.whl (110.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

nazo_image_utils-0.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (198.2 kB view details)

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

nazo_image_utils-0.0.4-cp39-cp39-macosx_11_0_x86_64.whl (42.1 kB view details)

Uploaded CPython 3.9 macOS 11.0+ x86-64

nazo_image_utils-0.0.4-cp38-cp38-win_amd64.whl (110.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

nazo_image_utils-0.0.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (195.6 kB view details)

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

nazo_image_utils-0.0.4-cp38-cp38-macosx_11_0_x86_64.whl (41.8 kB view details)

Uploaded CPython 3.8 macOS 11.0+ x86-64

File details

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

File metadata

  • Download URL: nazo_image_utils-0.0.4.tar.gz
  • Upload date:
  • Size: 80.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for nazo_image_utils-0.0.4.tar.gz
Algorithm Hash digest
SHA256 51642c44f50c1e9c8537ce56aedb2413269d1a9a8f43370cacc1d0719c417df7
MD5 1a1e0da1a7e46db5259dd0ef05554868
BLAKE2b-256 7cf1ea5cd8961a327672bc223434e8f359c7015f1c174ca69c37e9ce7cc89a76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a6a03a8ac783bd87aab4a1de7c7979da3a2bdee6c728186165b07b8c7b7c2ec5
MD5 fe56a9bc431548c10d93c579d610ca10
BLAKE2b-256 e9cdfe9b62ab0ae2ca38f4445c414b727642c327a8ab913a7178ce6a79a3b1fd

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-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.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f6d7c035c282ec8c5c3400c7e10cd7418fb89d1806fcb91ce3f8c897e9a918e3
MD5 f054d6ce5df7c6c1decb2b53f4a6030c
BLAKE2b-256 d6454a54356ea1aadd21a2104049e0ac17c3cd9e8f0b3aa08662a717802e463e

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-cp312-cp312-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0e75bd9450de00ced958586cc3c7c0caf2973bd12683100e6183594cd98701dd
MD5 ff435cd7c90a4410e5e424c84d88fd38
BLAKE2b-256 6213bcdbb1f7a92c04d9f80afad7c53b5bae4c6393f81f90f5458e8db28fcf1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3563c9b60f6b6e3d00f336483c9ad94e8350121afa6249f3952d8a17e4af2740
MD5 24f792d1c0725cf4bc6966b4529cef53
BLAKE2b-256 4091b85dbf562467e0d24c2fa862f6a91096346d175a0e4619cd0c3612d1cf5b

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-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.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b18653c11e95c3c0978caf9477edcae8264486dbb00a2147cb7f0687d97262da
MD5 8d012d3edc2aa46568d5f3a534962923
BLAKE2b-256 cb357c930d3400bcd7647b2c475ca5f478074b5fb64980dd6cd37f02fd1df5e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 776f7ce844e7f4e38bc65e814c189e6930c6281b208dd8aabe8284c853177341
MD5 d02f873faee49321d83025fffb544220
BLAKE2b-256 5cac65189907ad3e4b0abf6a2e55a6b5dda5aad8f4a5932ddd0d42120725f1e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 625ff99ab68549671bd8283155744da38639cadf16eab1916fe6466d010ce37b
MD5 e6d9e1a5a3cbd599e717094f4c27a2b5
BLAKE2b-256 6261d31ec51e41df342067e3be5fd4434c4e949f618fbd064ff70abdb4f71dba

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-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.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52422eb1d7212161e52779c40581679d57a32f9da2e8e92ea6ab58ee5377c714
MD5 5794a74f55d5ebd44565f692b86f5bf7
BLAKE2b-256 5fe4a86c3f1f1da3037c443378df1deb67429c2be3cadb4428dfb56e5e92ea20

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 51da138fe85eebedc1cf67317cc4e3855483fce0b048d96d38c74e3647350e5d
MD5 b9beaf804647534d62aa66c1bd7d9b2b
BLAKE2b-256 ae78e18753fe3cf7ece36c14059cf804e31b7000f661ebe103516380148c9fcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 606aa310889185d4cdc2e2911f304b55d3d1ea6e5402101b6fcab6c1361c0665
MD5 1374be17d8b8a7f54378b92d2c63133e
BLAKE2b-256 ceb597f501e5446cf27495d50aa9aed21fc7d2c79cca6245c5afb2a1afc4b31e

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-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.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00c7dd69162c2e1f5b61b96a122ede5e74afdfb78bf76d3b814b160a57c08eb8
MD5 cf2bc58da4ce51a03c1d70eec9bec300
BLAKE2b-256 362fb0ba6982adf929f9f919756d26ed53a97a519876a6e54fa83ef608a7dbc8

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 4371786d27a901a340c3c5b63ce6ca4fdecca468f07349f0085cb76c801db262
MD5 d9b135aabe6f3c36127bfec3da5d2ae7
BLAKE2b-256 1545a7e1c718bb8f76fd2516f123c8ef5ce17ba172fd5981e1d5f829b58cf93c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c38b5f0a2b1e7d339fcf976b8b8aea31c4cf3052a6b75b4855291a93748e43a0
MD5 3a2f5e389d678b76d52b54c691df7925
BLAKE2b-256 821d472dcfc109af43b0a1a33dba8c4410cee0c3fbe68d8f7eae6f0532307ed4

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-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.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aec2e541ffe6a89b3ff8969ffd0ef06cac4e7494d0ae79d81adc807bce471103
MD5 ce4cd903a20aba75a5fda4b708c6d928
BLAKE2b-256 06b0c049abf09ff8c2af7dd08a4d06e80aca25651dd8c46ccb2ce41324e2f499

See more details on using hashes here.

File details

Details for the file nazo_image_utils-0.0.4-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nazo_image_utils-0.0.4-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 0eaabeb1bcd69b1392e716a5bb822659f16d334f14b903b6a475af59a3ae03f2
MD5 30d88cdae3f648d63064deec63f13716
BLAKE2b-256 fd7bdeceda3467a4767f0f6e6d113eafe193df2564f2eab136b67dea8cb74080

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