Skip to main content

一个主流图片压缩方案的自动化脚本(利用 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)

Source distribution for img-compress-liuhuige 0.0.1
File Size Uploaded
img_compress_liuhuige-0.0.1.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for img-compress-liuhuige 0.0.1
File Interpreter ABI Platform
img_compress_liuhuige-0.0.1-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release 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