一个主流图片压缩方案的自动化脚本(利用 tinify 实现)
Project description
一个主流图片压缩方案的自动化脚本(利用 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密匙 -> 传送门
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file img_compress_liuhuige-0.0.1.tar.gz.
File metadata
- Download URL: img_compress_liuhuige-0.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01076ea9b6333e88a2748335c21609b4717410623cd18314f3bb28adffa402ed
|
|
| MD5 |
87905f70e3ccb9de76c131ec012f01aa
|
|
| BLAKE2b-256 |
b66b49cce9da6b467c37069b3d02908e7afb724ad3b8800e977be0849758ff7b
|
File details
Details for the file img_compress_liuhuige-0.0.1-py3-none-any.whl.
File metadata
- Download URL: img_compress_liuhuige-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
626c7c5ae30368a306b649972e055c2db493a2889ea7de8ba2d2285948cf6343
|
|
| MD5 |
900068ded62619cff359bb8c52179720
|
|
| BLAKE2b-256 |
3bd72dc6430aca67336a1c3761dca90c3e30441934220f79c809e63172331a6b
|