Skip to main content

一个主流图片压缩方案的自动化脚本(利用 tinify 实现)

Project description

一个主流图片压缩方案的自动化脚本(利用 tinify 实现)

实现三种图片输入的方式

  • 用户可以指定需要压缩的图片文件名称(支持多个图片文件,使用空格隔开)
  • 如果用户未指定图片,默认压缩当前文件夹下所有的 jpg/jpeg/png/webp 图片

支持图片的尺寸调整

  • 输入宽度和高度(比如 600 800),表示按比例缩小图片,使其适合给定的尺寸
  • 输入宽度(比如 600 0),表示按确定的宽度调整图片,高度适配
  • 输入高度(比如 0 800),表示按确定的高度调整图片,宽度适配
  • 如未输入宽度和高度,则表示按照原始分辨率来压缩图片

调用方法

import img_compress

img_compress.tinify.key = "" # 请在https://tinify.cn/developers申请密匙
img_compress.compress() # 可以指定多个图片文件,未指定则压缩当前路径下的图片

注意:需先到tifiny官网申请API密匙 -> 传送门

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

img_compress-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

img_compress-0.0.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file img_compress-0.0.3.tar.gz.

File metadata

  • Download URL: img_compress-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for img_compress-0.0.3.tar.gz
Algorithm Hash digest
SHA256 918822eb065e2de364f87a956fcda825b5dac8590f5471989fb11244be586abf
MD5 9b65db9506727554136e0ad3ad0a5975
BLAKE2b-256 f9eb2fa4dbd022ea444ef7e8fdfe507f42fa6e88ab34c5dacf5447288727b0e7

See more details on using hashes here.

File details

Details for the file img_compress-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: img_compress-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for img_compress-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fc2b48bfcdfdb05d925a979388e133ae81e015a6883070867e7924a3bfdf82f8
MD5 a57966806dca090d098b8b7a441ea48b
BLAKE2b-256 7d505c3d4e169b325eddbc93a87b2971c8c5fde1f5617d265693fa59538b7280

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