Skip to content

@tank/unix-media-compressor

1.0.0
Skill

Description

Compress any file on macOS/Linux. Images (JPEG, PNG, WebP, AVIF, GIF), video (H.264/H.265/AV1), audio (MP3/AAC/Opus/FLAC), PDFs (Ghostscript), archives (zip, tar.gz, 7z, zstd, brotli). Auto-detects tools, guides installation, batch operations.

Triggered by

compressshrinkoptimizereduce file sizeimage compressionvideo compression
Download
Review Recommended
tank install @tank/unix-media-compressor

Unix Media Compressor

Compress any file to its smallest practical size on macOS and Linux.

Core Philosophy

  1. Right tool for the job — Each file type has a best-in-class compressor. JPEG and PNG need different tools. Video and audio need different codecs. Match the tool to the content.
  2. Quality tiers, not magic numbers — Three tiers for every domain: "web" (aggressive, smallest), "balanced" (good quality, reasonable size), and "quality" (visually/audibly lossless). Pick a tier, get the right settings.
  3. Detect before compressing — Run scripts/check-tools.sh first. Know what tools are available. Install missing ones. Do not guess.
  4. Preserve originals by default — Output to a new file unless the user explicitly asks to overwrite. Compression is lossy and irreversible for most formats.
  5. Show the results — Always report before/after file sizes and percentage reduction. Compression without measurement is guessing.

Quick-Start

What are you compressing?

File TypeBest ToolStart Here
JPEG photosmozjpeg or jpegoptimreferences/image-compression.md
PNG graphicspngquant + oxipngreferences/image-compression.md
Convert to WebPcwebpreferences/image-compression.md
Convert to AVIFavifencreferences/image-compression.md
GIF animationgifsiclereferences/image-compression.md
Video (any format)ffmpeg (libx264/libx265/libsvtav1)references/video-compression.md
Audio (any format)ffmpeg (libopus/aac/libmp3lame)references/audio-compression.md
PDF documentsGhostscript (gs)references/pdf-compression.md
Folder / multiple fileszip, tar.zst, 7zreferences/archive-formats.md
Missing tools?check-tools.shreferences/tool-setup.md

Quality Tier Quick Reference

TierImagesVideo (H.264)Audio (Opus)PDF
Webcwebp -q 75CRF 28, fast64-96k/screen (72 DPI)
Balancedcwebp -q 85CRF 22, slow128k/ebook (150 DPI)
Qualitycwebp -q 92CRF 18, veryslow192k/printer (300 DPI)

Common Workflows

Compress all images in a folder

# Check tools first
bash scripts/check-tools.sh

# JPEG: optimize in-place
jpegoptim --max=85 --strip-all *.jpg

# PNG: lossy + lossless pipeline
pngquant --quality 65-80 --force --ext .png *.png
oxipng -o 3 -i 0 --strip safe *.png

# Convert all to WebP
for f in *.jpg *.png; do cwebp -q 85 "$f" -o "${f%.*}.webp"; done

Compress a video for web

ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium \
  -pix_fmt yuv420p -c:a aac -b:a 128k \
  -movflags +faststart output.mp4

Compress a PDF

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
   -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Archive a folder (best speed/ratio)

tar -cf - ./folder/ | zstd -3 -T0 -o folder.tar.zst

Decision Trees

Which video codec?

PriorityCodecEncoderWhen
Max compatibilityH.264libx264Web, mobile, legacy devices
Better compressionH.265libx2654K, storage savings, modern devices
Best compressionAV1libsvtav1Modern web, encode time acceptable

Which archive format?

PriorityFormatWhen
Cross-platformzipSharing with Windows/Mac users
Best speed+ratiotar.zstBackups, pipelines, general use
Maximum ratio7zArchival, maximum compression needed
Web assetsbrotliPre-compressing JS/CSS for HTTP

Troubleshooting

ProblemCauseFix
"command not found"Tool not installedRun bash scripts/check-tools.sh --install
Output larger than inputAlready optimized or wrong settingsTry different quality tier or tool
Video has no audioMissing -c:a flagAdd -c:a aac -b:a 128k
H.265 won't play on iPhoneMissing tagAdd -tag:v hvc1
PNG barely shrinksAlready optimized or few colorsTry pngquant (lossy) before oxipng
ffmpeg "width not divisible by 2"Odd resolutionUse scale=WIDTH:-2
Ghostscript font errorsMissing fontsAdd -dSubsetFonts=true

Reference Files

FileContents
references/image-compression.mdJPEG (mozjpeg, jpegoptim), PNG (pngquant+oxipng), WebP (cwebp), AVIF (avifenc), GIF (gifsicle), format selection, quality presets, batch processing
references/video-compression.mdH.264/H.265/AV1 codecs, CRF quality tiers, resolution scaling, two-pass encoding, hardware acceleration, audio handling, batch video
references/audio-compression.mdMP3/AAC/Opus/FLAC codecs, quality tiers, codec selection guide, extract audio from video, batch audio
references/pdf-compression.mdGhostscript quality presets (/screen through /prepress), advanced optimization flags, qpdf, batch PDF compression
references/archive-formats.mdzip, tar.gz, tar.xz, tar.zst, 7z, brotli, format comparison, parallel compression (pigz, pbzip2), format selection guide
references/tool-setup.mdTool detection, macOS/Linux installation, batch processing patterns, before/after reporting, preserving originals

Scripts

ScriptUsage
scripts/check-tools.shDetect installed tools, suggest missing. Flags: --json (JSON output), --install (auto-install missing via brew/apt)

Command Palette

Search packages, docs, and navigate Tank