npx skills add ...
npx skills add zc277584121/marketing-skills --skill screenshot-compression
Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
npx skills add zc277584121/marketing-skills --skill screenshot-compression
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 | 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.
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:
| 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) |
| 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.# 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