一个主流图片压缩方案的自动化脚本(利用 tinify 实现)
实现三种图片输入的方式
- 用户可以指定需要压缩的图片文件名称(支持多个图片文件,使用空格隔开)
- 如果用户未指定图片,默认压缩当前文件夹下所有的 Jpg/jpeg/png/webp 图片
支持图片的尺寸调整
- 输入宽度和高度(比如 600 800),表示按比例缩小图片,使其适合给定的尺寸
- 输入宽度(比如 600 0),表示按确定的宽度调整图片,高度适配
- 输入高度(比如 0 880),表示按确定的高度调整图片,宽度适配
- 如未输入宽度和高度,则表示按照原始分辨率来压缩图片
调用方法
import img_compress img_compress.tinify.key = "" # 请在https://tinify.cn/developers申请密匙 img_compress.compress() # 可以指定多个图片文件,未指定则压缩当前路径下的图片
注意:需先到tinfiny官网申请API密匙 -> 传送门
Metadata
Release files for img-compress-liuhuige 0.0.1
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 |
|---|---|---|---|---|
| img_compress_liuhuige-0.0.1.tar.gz | 2.8 kB | Without provenance | Details for img_compress_liuhuige-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| img_compress_liuhuige-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for img_compress_liuhuige-0.0.1-py3-none-any.whl |
Total release size: 5.9 kB
Release files / img_compress_liuhuige-0.0.1.tar.gz
| Download URL | img_compress_liuhuige-0.0.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01076ea9b6333e88a2748335c21609b4717410623cd18314f3bb28adffa402ed
|
|
BLAKE2b-256 checksum How to use checksums |
b66b49cce9da6b467c37069b3d02908e7afb724ad3b8800e977be0849758ff7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / img_compress_liuhuige-0.0.1-py3-none-any.whl
| Download URL | img_compress_liuhuige-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
626c7c5ae30368a306b649972e055c2db493a2889ea7de8ba2d2285948cf6343
|
|
BLAKE2b-256 checksum How to use checksums |
3bd72dc6430aca67336a1c3761dca90c3e30441934220f79c809e63172331a6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for img-compress-liuhuige 0.0.1
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.