支持 PNG, JPEG, WebP 等格式的智能图片压缩工具,在不改变图片质量的情况下尽可能压缩体积
- 🖼️ 多格式支持: PNG, JPEG, WebP, BMP, TIFF
- 🚀 智能压缩: 自动选择最佳压缩算法
- 📊 元数据保留: 完整保留 EXIF、XMP、ICC Profile 等元数据
- 📁 批量处理: 支持目录批量压缩和递归处理
- 🎯 多种预设: fast (快速), balanced (平衡), quality (高质量)
- 📈 实时进度: 显示压缩进度、时间和压缩率
# 下载对应平台的可执行文件
chmod +x tinypng
./tinypng --helpgit clone https://github.com/yourusername/tinypng-cli.git
cd tinypng-cli
pip3 install -r requirements.txt
python3 tinypng_cli.py --help# 压缩单张图片
tinypng image.png
# 指定输出文件
tinypng image.png -o compressed.png
# 指定输出格式
tinypng image.png -f jpg -o compressed.jpg
# 批量压缩目录
tinypng images/ -d compressed/
# 递归批量压缩
tinypng images/ -r -d compressed/# 设置 JPEG/WebP 质量
tinypng image.jpeg -q 85
# 选择压缩预设
tinypng image.jpeg --preset fast # 快速压缩
tinypng image.jpeg --preset balanced # 平衡压缩 (默认)
tinypng image.jpeg --preset quality # 高质量压缩
# 覆盖已存在的文件
tinypng image.png --overwrite# 批量压缩当前目录所有图片
tinypng . -d compressed/
# 递归处理子目录
tinypng . -r -d compressed/
# 批量转换为特定格式
tinypng . -f webp -d webp_output/# 构建可执行文件
make build-executable
# 安装到系统
make install-executable
# 查看所有可用命令
make help# 默认构建
./build.sh
# 目录模式构建 (启动更快)
./build.sh --mode onedir
# 构建并安装
./build.sh --install- macOS: 10.13+ (Intel/Apple Silicon)
- Linux: Ubuntu 18.04+, CentOS 7+
- Windows: Windows 10+ (需要额外配置)
- Python: 3.7+ (仅构建时需要)
# 检查文件权限
chmod +x ./dist/tinypng
# 重新构建
make clean
make build-executable- 项目配置: pyproject.toml
- 构建配置: pyinstaller_config.spec
欢迎提交 Issue 和 Pull Request!
本项目采用 Apache 2.0 许可证 - 查看 LICENSE 文件了解详情。