This skill should be used when optimizing, converting, or resizing images. Trigger when user mentions image optimization, HEIC/HEIF conversion, JPEG/PNG/WebP/AVIF processing, reducing image file size, or batch image processing. Uses sharp-cli as the primary tool.
Optimize and convert images for various use cases using sharp-cli.
sharp --help for full reference.Determine what images to process:
*.HEIC, *.jpg)If matching a reference image:
file reference.webp # Get format and dimensions
ls -lah reference.webp # Get file size
Extract: format, dimensions (width x height), approximate file size.
Ask user for unclear parameters. Smart defaults by use case:
Presets: | Preset | Size | Quality | Options | |--------|------|---------|---------| | web | 1920px | 78 | progressive, mozjpeg | | standard | 2560px | 90 | mozjpeg, metadata | | high | 3500px | 90 | 4:4:4 chroma, metadata | | extra-high | 4000px | 95 | 4:4:4 chroma, metadata |
Parameters:
Convert HEIC/HEIF to JPEG first:
for f in *.HEIC *.heic; do
[[ -f "$f" ]] || continue
heif-convert -q 90 "$f" "${f%.*}.jpg"
done
Then process resulting JPEGs with sharp.
Structure: sharp -i <input> -o <output-dir> [options] [resize <w> <h>]
Key options:
| Option | Description |
|--------|-------------|
| -f webp/jpeg/png/avif | Output format |
| -q <1-100> | Quality |
| -p / --progressive | Progressive JPEG |
| --mozjpeg | Better compression |
| -m / --withMetadata | Preserve EXIF |
| --chromaSubsampling '4:4:4' | High quality chroma |
| resize <w> <h> --fit inside | Resize maintaining aspect ratio |
Examples:
# Web-optimized
sharp -i *.jpg -o ./optimized resize 1920 1920 --fit inside -q 78 -p --mozjpeg
# Standard with metadata
sharp -i *.jpg -o ./ resize 2560 2560 --fit inside -q 90 --mozjpeg -m
# High quality
sharp -i *.jpg -o ./ resize 3500 3500 --fit inside -q 90 --chromaSubsampling '4:4:4' -m
# Convert to WebP
sharp -i *.jpg -o ./webp -f webp resize 1920 1920 --fit inside -q 80
# Match reference (2200x980 webp)
sharp -i input.png -o . -f webp -q 80 resize 2200 980
--fit inside for resize to maintain aspect ratiofile for dimensions/format, ls -lah for sizeEdit PDFs with natural-language instructions using the nano-pdf CLI.
Control Sonos speakers (discover/status/play/volume/group).
Terminal Spotify playback/search via spogo (preferred) or spotify_player.
Capture frames or clips from RTSP/ONVIF cameras.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.
Category:tools