npx skills add https://github.com/zc277584121/marketing-skills --skill screenshot-compression原地压缩截图图像(PNG/JPEG),同时保持原始格式。使用 pngquant 处理 PNG,使用 jpegoptim 处理 JPEG——两者对于截图内容(UI 元素、文本、纯色)都非常有效。
先决条件:系统中必须安装
pngquant和jpegoptim。脚本不会自动安装它们——它会检查它们是否存在,如果缺失则打印安装说明。
用户有截图文件过大,并希望在不改变格式的情况下减小文件大小。常见场景:
WebP 压缩效果更好,但在某些环境下兼容性差:
| 环境 | WebP 支持 |
|---|---|
| 浏览器(Chrome/Firefox/Safari/Edge) | 是 |
| GitHub Issues/PRs |
Compress screenshot images (PNG/JPEG) in place while keeping the original format. Uses pngquant for PNG and jpegoptim for JPEG — both are highly effective for screenshot content (UI elements, text, flat colors).
Prerequisites :
pngquantandjpegoptimmust be installed on the system. The script will not install them automatically — it checks for their presence and prints install instructions if missing.
The user has screenshot files that are too large and wants to reduce file size without changing format. Common scenarios:
WebP has better compression, but poor compatibility in some contexts:
| Context |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 是 |
| 微信编辑器 | 否 |
| Word / PowerPoint | 否 |
| 某些论坛/博客后端 | 视情况而定 |
保持 PNG/JPEG 格式可确保压缩后的图像在任何地方都能使用。
python /path/to/skills/screenshot-compression/scripts/compress_screenshots.py <files-or-directories>
脚本将:
pngquant 和 jpegoptim 是否已安装——如果未安装,则打印安装说明并退出脚本需要两个系统工具。如果任一缺失,脚本将退出并显示安装说明,而不是继续执行。不要代表用户安装它们——只需传递错误消息,以便用户自行安装。
安装命令:
# macOS
brew install pngquant jpegoptim
# Ubuntu / Debian
sudo apt install pngquant jpegoptim
# CentOS / RHEL
sudo yum install pngquant jpegoptim
| 标志 | 默认值 | 描述 |
|---|---|---|
paths (位置参数) | 必需 | 要压缩的图像文件或目录 |
-r, --recursive | 关闭 | 递归处理目录 |
--png-quality | 80-95 | pngquant 质量范围(最小值-最大值,0-100) |
--jpeg-quality | 85 | jpegoptim 最大质量(0-100) |
# 压缩单个文件
python .../compress_screenshots.py screenshot.png
# 压缩目录中的所有图像
python .../compress_screenshots.py ./images/
# 递归目录扫描
python .../compress_screenshots.py ./docs/ --recursive
# 代码截图的高质量设置
python .../compress_screenshots.py *.png --png-quality 90-100
# 缩略图的激进压缩
python .../compress_screenshots.py *.jpg --jpeg-quality 70
| 场景 | --png-quality | --jpeg-quality |
|---|---|---|
| 通用截图(文档、网页) | 80-95 | 85 |
| 代码截图(需要清晰的文本) | 90-100 | 90 |
| 缩略图 / 预览(大小优先) | 60-80 | 70 |
--strip-all 剥离元数据(EXIF、ICC 配置文件、缩略图).png、.jpg 和 .jpeg 文件。其他格式会被静默跳过。每周安装数
121
代码仓库
首次出现
2026年3月5日
安全审计
安装于
amp121
github-copilot121
codex121
kimi-cli121
gemini-cli121
cursor121
| WebP Support |
|---|
| Browsers (Chrome/Firefox/Safari/Edge) | Yes |
| GitHub Issues/PRs | Yes |
| WeChat editor | No |
| Word / PowerPoint | No |
| Some forums/blog backends | Varies |
Keeping PNG/JPEG ensures the compressed images work everywhere.
python /path/to/skills/screenshot-compression/scripts/compress_screenshots.py <files-or-directories>
The script will:
pngquant and jpegoptim are installed — if not, print install instructions and exitThe script requires two system tools. If either is missing, it exits with install instructions instead of proceeding. Do not install them on behalf of the user — just relay the error message so the user can install them.
Install commands:
# macOS
brew install pngquant jpegoptim
# Ubuntu / Debian
sudo apt install pngquant jpegoptim
# CentOS / RHEL
sudo yum install pngquant jpegoptim
| Flag | Default | Description |
|---|---|---|
paths (positional) | required | Image files or directories to compress |
-r, --recursive | off | Recursively process directories |
--png-quality | 80-95 | pngquant quality range (min-max, 0-100) |
--jpeg-quality | 85 | jpegoptim max quality (0-100) |
# Compress a single file
python .../compress_screenshots.py screenshot.png
# Compress all images in a directory
python .../compress_screenshots.py ./images/
# Recursive directory scan
python .../compress_screenshots.py ./docs/ --recursive
# High quality for code screenshots
python .../compress_screenshots.py *.png --png-quality 90-100
# Aggressive compression for thumbnails
python .../compress_screenshots.py *.jpg --jpeg-quality 70
| Scenario | --png-quality | --jpeg-quality |
|---|---|---|
| General screenshots (docs, web pages) | 80-95 | 85 |
| Code screenshots (need sharp text) | 90-100 | 90 |
| Thumbnails / previews (size priority) | 60-80 | 70 |
--strip-all.png, .jpg, and .jpeg files are processed. Other formats are silently skipped.Weekly Installs
121
Repository
First Seen
Mar 5, 2026
Security Audits
Installed on
amp121
github-copilot121
codex121
kimi-cli121
gemini-cli121
cursor121
Azure RBAC 权限管理工具:查找最小角色、创建自定义角色与自动化分配
131,500 周安装