惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
月光博客
月光博客
V
Visual Studio Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
Jina AI
Jina AI
J
Java Code Geeks
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
Recorded Future
Recorded Future
C
Check Point Blog
腾讯CDC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
罗磊的独立博客
Hacker News: Ask HN
Hacker News: Ask HN
SecWiki News
SecWiki News
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News | PayPal Newsroom
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Cloudbric
Cloudbric
F
Full Disclosure
The Cloudflare Blog
Y
Y Combinator Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
AI
AI
N
News and Events Feed by Topic
T
Tor Project blog
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers Blog

思有云 - IOIOX - Python

CentOS 7 从Python2.7.5升级到Python2.7.16版本教程 - 思有云 CentOS 7 配置Python3环境教程 - 思有云
TinyPNG批量压缩图片Python脚本使用教程 - 思有云 - IOIOX
博主: Stille · 2019-05-09 · via 思有云 - IOIOX - Python
  • 发布时间:
  • 15563 次浏览
  • 7 条评论
  • 977字数
  • 分类: 技术教程
  1. 首页
  2. 正文  

前言

TinyPNG是一个免费的在线批量压缩图片服务,但Web端有单次20张和单个文件5M的限制.同时TinyPNG官方提供了API,API限制每月500张,完全满足个人使用.本文将介绍使用Python脚本来批量压缩图片.

推荐使用场景

大部分博主们都苦于文章中的图片过大,导致网站访问速度过慢,或者浪费存储的空间和CDN的流量.我们可以直接在服务器上的图片文件夹内运行此脚本来批量压缩.

本文为 Stille 原创文章.经实践,测试,整理发布.如需转载请联系作者获得授权,并注明转载地址.


安装流程

Python环境

  • Linux的Python环境搭建请自行解决,macOS已自带Python环境.
  • 安装pip包管理器

    sudo easy_install pip
  • pip安装tinify

    sudo pip install --upgrade tinify

准备API及脚本

运行使用

  • 把tinypng.py移动到需要压缩图片的文件夹内
  • 终端进入该目录,运行即可.

    python tinypng.py

如果遇到click错误提示,需pip安装click.

sudo pip install click

结语

TinyPNG的脚本还有更多的玩法和参数,请参考作者GitHub


晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. 晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。
RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。

赞赏作者

如果喜欢我的文章,觉得对你有帮助,请随意赞赏!

TinyPNG批量压缩图片Python脚本使用教程

 •