GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - saitjr/STTinyPNG-Python: TinyPNG 批量压缩图片脚本

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
STTinyPNG-Python.py
STTinyPNG-Python.py
 
 

Repository files navigation

STTinyPNG-Python

TinyPNG 批量压缩图片脚本

待解决的问题 : 请保持文件路径中没有中文 (文件名可以是中文)

一、环境配置

别被这四个字吓到了,只需要一行命令。

首先,电脑需要有 Python 环境,正好 Mac 自带 Python 环境。然后,安装 TinyPNG 的库:

sudo pip install --upgrade tinify

ok,环境配置到此结束。

二、申请 AppKey

到 TinyPNG 网站上去申请 AppKey,唯一不是很爽的就是一个月只能压缩 500 张(但这不是没限制你可以注册多少个吗…)。填写名字和邮箱,验证以后就可以获得 AppKey 了,很方便。

三、下载并运行脚本

打开 STTinyPNG-Python.py ,填写你的 AppKey、图片文件夹路径、图片输出文件夹路径(输出文件夹空的就行,如果图片里的文件夹目录不存在,会自动创建)。

tinify.key = "your AppKey" # AppKey
fromFilePath = "/Users/tangjr/Desktop/test1" # 源路径
toFilePath = "/Users/tangjr/Desktop/test2"   # 输出路径

ok,运行脚本。打开终端:

python /Users/tangjr/Documents/STTinyPNG-Python/STTinyPNG-Python.py

Done !

四、简单说一下思路

使用 Python 的 os 库,遍历源文件夹,找到 .png 或 .jpg 文件,则进行压缩( TinyPNG 只支持这两种图片类型)。

恩,就这么简单,没了...

About

TinyPNG 批量压缩图片脚本

Resources

Readme
MIT license
Activity

Stars

61 stars

Watchers

3 watching

Forks

20 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.