screenshot-compression
Compress PNG and JPEG screenshots in place using pngquant and jpegoptim, keeping the original format for maximum compatibility.
Security Assessment
Detected risks:
About screenshot-compression
Screenshot Compression reduces the file size of PNG and JPEG screenshots in place while preserving the original file format, so the compressed images keep working everywhere. It wraps two established command-line tools, pngquant for PNG and jpegoptim for JPEG, both of which are particularly effective on screenshot content such as UI elements, text, and flat color regions. A Python script (compress_screenshots.py) accepts one or more files or directories, auto-detects each file's format by extension, compresses it, and prints a per-file and total compression summary.
The format-preserving approach is deliberate. WebP compresses better but has gaps in compatibility: it is not supported by the WeChat editor, Word, or PowerPoint, and support varies across forums and blog backends. Keeping PNG and JPEG guarantees the results embed cleanly in GitHub READMEs, documentation, blog posts, and office documents. Typical use cases are shrinking images before committing them to a repository or batch-compressing a directory of screenshots.
Behavior is controlled with a few options: a required positional list of paths, -r/--recursive to descend into directories, --png-quality (default 80-95, a pngquant min-max range) and --jpeg-quality (default 85). Under the hood, pngquant quantizes 24-bit true color down to an 8-bit 256-color palette with Floyd-Steinberg dithering, typically cutting 60 to 80 percent, while jpegoptim re-encodes at the chosen quality, strips metadata via --strip-all, and optimizes Huffman tables for a 20 to 50 percent reduction. A quality tuning guide suggests higher settings for code screenshots that need sharp text and more aggressive settings for thumbnails. Two important caveats apply: files are overwritten in place, so back up originals first if needed, and pngquant and jpegoptim must already be installed. The script checks for them and prints platform-specific install instructions (brew, apt, or yum) if either is missing, but never installs them itself. Only .png, .jpg, and .jpeg files are processed; other formats are silently skipped.
FAQ
Does the script install pngquant and jpegoptim for me?
No. It checks whether both are present and, if either is missing, prints platform-specific install instructions (brew, apt, or yum) and exits without installing anything.
Why keep PNG/JPEG instead of converting to WebP?
WebP compresses better but is not supported in contexts like the WeChat editor, Word, or PowerPoint. Keeping the original format ensures the compressed images work everywhere.
Are my original files preserved?
No. Files are compressed in place and the original is overwritten, so back them up first if you need to keep them.
How do I adjust compression quality?
Use --png-quality (default 80-95) and --jpeg-quality (default 85). The tuning guide suggests higher values for code screenshots that need sharp text and lower values for thumbnails.
Can it process a whole folder of images?
Yes. Pass a directory as a path, and add -r/--recursive to descend into subdirectories. Only .png, .jpg, and .jpeg files are compressed; other formats are skipped.
Install screenshot-compression
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
zc277584121/marketing-skills