
Screenshot Compression
- 2.8k installs
- Updated July 30, 2026
- zc277584121/marketing-skills
screenshot-compression is an agent skill that Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compati.
About
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 pngquant and jpegoptim must 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 Preparing images for GitHub READMEs blog posts or documentation Reducing image sizes before committing to a repository Batch compressing a directory of screenshots 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
- description: Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for ma
- Compress screenshot images (PNG/JPEG) in place while keeping the original format. Uses `pngquant` for PNG and `jpegoptim
- > **Prerequisites**: `pngquant` and `jpegoptim` must be installed on the system. The script will **not** install them au
- Follow screenshot-compression SKILL.md steps and documented constraints.
- Follow screenshot-compression SKILL.md steps and documented constraints.
Screenshot Compression by the numbers
- 2,789 all-time installs (skills.sh)
- +219 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #284 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 4, 2026 (Skillselion catalog sync)
screenshot-compression capabilities & compatibility
- Capabilities
- description: compress png and jpeg screenshots i · compress screenshot images (png/jpeg) in place w · > **prerequisites**: `pngquant` and `jpegoptim` · follow screenshot compression skill.md steps and
- Use cases
- orchestration
What screenshot-compression says it does
description: Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
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
> **Prerequisites**: `pngquant` and `jpegoptim` must be installed on the system. The script will **not** install them automatically — it checks for their presence and prints install instructions if mi
npx skills add https://github.com/zc277584121/marketing-skills --skill screenshot-compressionAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2.8k |
|---|---|
| Security audit | 3 / 3 scanners passed |
| Last updated | July 30, 2026 |
| Repository | zc277584121/marketing-skills ↗ |
When should an agent use screenshot-compression and what problem does it solve?
Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
Who is it for?
Developers invoking screenshot-compression as documented in the skill source.
Skip if: Skip when requirements fall outside screenshot-compression documented scope.
When should I use this skill?
Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
What you get
Outputs aligned with the screenshot-compression SKILL.md workflow and stated deliverables.
- Compressed PNG screenshots
- Compressed JPEG screenshots
Files
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.
---
When to Use
The user has screenshot files that are too large and wants to reduce file size without changing format. Common scenarios:
- Preparing images for GitHub READMEs, blog posts, or documentation
- Reducing image sizes before committing to a repository
- Batch compressing a directory of screenshots
---
Why Keep Original Format (Not WebP)
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.
---
Default Workflow
python /path/to/skills/screenshot-compression/scripts/compress_screenshots.py <files-or-directories>The script will: 1. Check that pngquant and jpegoptim are installed — if not, print install instructions and exit 2. Auto-detect file format by extension 3. Compress each file in place (overwrites the original) 4. Print per-file and total compression summary
---
Dependency Check
The 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---
Script Options
| 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) |
---
Examples
# 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---
Quality Tuning Guide
| 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 |
---
How It Works
PNG (pngquant)
- Quantizes 24-bit true color (16M colors) down to an 8-bit palette (256 colors)
- Uses Floyd-Steinberg dithering for smooth gradients
- Screenshots are ideal candidates — UI colors are typically well under 256 unique values
- Typical reduction: 60-80%
JPEG (jpegoptim)
- Re-encodes at the specified quality level
- Strips metadata (EXIF, ICC profiles, thumbnails) via
--strip-all - Optimizes Huffman tables
- Typical reduction: 20-50%
---
Important Notes
- Files are compressed in place — the original is overwritten. Back up files first if needed.
- Only
.png,.jpg, and.jpegfiles are processed. Other formats are silently skipped. - The script never installs dependencies. If tools are missing, it prints install instructions and exits.
#!/usr/bin/env python3
"""
Compress screenshot images (PNG/JPEG) in place using pngquant and jpegoptim.
Requires system tools: pngquant (for PNG), jpegoptim (for JPEG).
These must be installed separately — the script will check and exit with
clear instructions if they are missing.
Usage:
python compress_screenshots.py image1.png image2.jpg
python compress_screenshots.py /path/to/screenshots/
python compress_screenshots.py /path/to/screenshots/ --recursive
python compress_screenshots.py *.png --png-quality 90-100
python compress_screenshots.py *.jpg --jpeg-quality 90
"""
import argparse
import shutil
import subprocess
import sys
from pathlib import Path
SUPPORTED_EXTENSIONS = {".png", ".jpg", ".jpeg"}
def check_dependencies() -> list[str]:
"""Check if required system tools are installed. Return list of missing ones."""
missing = []
if not shutil.which("pngquant"):
missing.append("pngquant")
if not shutil.which("jpegoptim"):
missing.append("jpegoptim")
return missing
def compress_image(
path: Path, png_quality: str = "80-95", jpeg_quality: int = 85
) -> dict | None:
"""Compress a single image file in place. Returns metadata dict or None if skipped."""
ext = path.suffix.lower()
if ext not in SUPPORTED_EXTENSIONS:
return None
old_size = path.stat().st_size
if ext == ".png":
subprocess.run(
[
"pngquant",
f"--quality={png_quality}",
"--force",
"--ext",
".png",
str(path),
],
capture_output=True,
)
elif ext in (".jpg", ".jpeg"):
subprocess.run(
["jpegoptim", f"--max={jpeg_quality}", "--strip-all", str(path)],
capture_output=True,
)
new_size = path.stat().st_size
return {
"file": str(path),
"name": path.name,
"old_kb": old_size / 1024,
"new_kb": new_size / 1024,
"reduction_pct": 100 - new_size * 100 // old_size if old_size > 0 else 0,
}
def collect_files(paths: list[str], recursive: bool = False) -> list[Path]:
"""Collect all supported image files from the given paths."""
files = []
for p_str in paths:
p = Path(p_str)
if p.is_file() and p.suffix.lower() in SUPPORTED_EXTENSIONS:
files.append(p)
elif p.is_dir():
pattern = "**/*" if recursive else "*"
for f in p.glob(pattern):
if f.is_file() and f.suffix.lower() in SUPPORTED_EXTENSIONS:
files.append(f)
return sorted(set(files))
def main():
parser = argparse.ArgumentParser(
description="Compress PNG/JPEG screenshots in place using pngquant and jpegoptim."
)
parser.add_argument(
"paths",
nargs="+",
help="Image files or directories to compress",
)
parser.add_argument(
"--recursive", "-r",
action="store_true",
help="Recursively process directories",
)
parser.add_argument(
"--png-quality",
default="80-95",
help="pngquant quality range (default: 80-95)",
)
parser.add_argument(
"--jpeg-quality",
type=int,
default=85,
help="jpegoptim max quality (default: 85)",
)
args = parser.parse_args()
# Check dependencies before doing anything
missing = check_dependencies()
if missing:
print("Error: the following required tools are not installed:")
for tool in missing:
print(f" - {tool}")
print()
print("Please install them before running this script:")
print()
print(" # macOS")
print(f" brew install {' '.join(missing)}")
print()
print(" # Ubuntu / Debian")
print(f" sudo apt install {' '.join(missing)}")
print()
print(" # CentOS / RHEL")
print(f" sudo yum install {' '.join(missing)}")
sys.exit(1)
files = collect_files(args.paths, recursive=args.recursive)
if not files:
print("No supported image files found (PNG/JPEG).")
sys.exit(0)
print(f"Compressing {len(files)} image(s)...")
print(f" PNG quality: {args.png_quality} | JPEG quality: {args.jpeg_quality}")
print()
results = []
for f in files:
result = compress_image(f, args.png_quality, args.jpeg_quality)
if result:
results.append(result)
print(
f" {result['name']}: {result['old_kb']:.0f} KB -> "
f"{result['new_kb']:.0f} KB ({result['reduction_pct']}% reduction)"
)
# Summary
if results:
total_old = sum(r["old_kb"] for r in results)
total_new = sum(r["new_kb"] for r in results)
total_saved = total_old - total_new
total_pct = 100 - int(total_new * 100 / total_old) if total_old > 0 else 0
print()
print(f"Done! {len(results)} files compressed.")
print(f"Total: {total_old:.0f} KB -> {total_new:.0f} KB "
f"(saved {total_saved:.0f} KB, {total_pct}% reduction)")
if __name__ == "__main__":
main()
Related skills
How it compares
Pick screenshot-compression over manual export sliders when you need repeatable CLI batch passes across docs or marketing screenshot folders.
FAQ
What is screenshot-compression?
Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
When should I use screenshot-compression?
Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
Is screenshot-compression safe to install?
Review the Security Audits panel on this page before production use.