Use when: compressing images, reducing image file size, optimizing images for the web, shrinking PNGs or JPEGs, reducing page weight from images. Also use when: adding an image (e.g. 'add image X') — always compress before inserting the image tag. Uses macOS sips to resize and re-encode images without noticeable quality loss.
Use macOS built-in sips — no install required.
| Format | Max longest edge | Quality |
|---|---|---|
| JPEG | 1200 px | 90% |
| PNG | 1200 px | — |
These values keep images visually indistinguishable from the originals while cutting file sizes by 60–80%. Do not lower quality below 90% or resize below 1200 px unless the user explicitly asks.
Screenshots with text: Check the original pixel dimensions with sips --getProperty pixelWidth before resizing. If the longest edge is already ≤ 1400 px, skip the resize step entirely — resizing screenshots down causes blurry text. Do not use -Z in a way that would upscale the image.
List the target directory to identify all images:
ls -lh assets/img/<subdir>/
Rename screenshots to clean, descriptive names based on context:
zoho-t1-execution-time.png).Screenshot 2026-04-13 at 2.40.18 PM.png). Never try to type or paste these filenames directly. Instead, use zsh (@f) flag to load paths into an array safely, then reference by index to rename:
FILES=("${(@f)$(find "$DIR" -name "Screenshot*.png" | sort)}")
mv "${FILES[1]}" "$DIR/my-descriptive-name-1.png"
mv "${FILES[2]}" "$DIR/my-descriptive-name-2.png"
Run the interactive compress-images.sh script with the list of files to process:
bash .github/skills/compress-images/compress-images.sh assets/img/<subdir>/file1.jpeg assets/img/<subdir>/file2.png
Follow the interactive prompts:
n, it restores them.Update any image references in post files if filenames were also renamed.
bash .github/skills/compress-images/compress-images.sh instead of manual sips commands when possible."My File.jpeg" — do not rely on glob expansion.sips -Z only resizes; it does not reduce bit depth or palette. For further PNG reduction, a separate tool (e.g. pngquant) would be needed — do not use without user confirmation.