Image compress

From ferologics/pi-skills · View interactive version

Image compress is an AI agent skill from the GitHub repository ferologics/pi-skills. Compress images to a target file size using macOS sips. No dependencies required.

How to use this skill

Skill file

Image Compress Skill

Compress images to a target file size using macOS built-in sips. Works with PNG, JPEG, HEIC, TIFF, and more.

Usage

~/dev/pi-skills/image-compress/compress.sh <input> [output] [options]

Options:

If no output is specified, creates <input>_compressed.<ext> in the same directory.

Examples

# Compress to 5MB (default), auto-resize
compress.sh photo.png

# Target 2MB
compress.sh photo.png out.png --target 2

# Convert to JPEG (often much smaller)
compress.sh photo.png out.jpg --format jpeg

# Specific width
compress.sh photo.png out.png --width 2000

# High quality JPEG
compress.sh photo.png out.jpg --format jpeg --quality 95

How it works

  1. Gets current dimensions and file size
  2. Strips ICC color profile (avoids sips warnings)
  3. If format conversion requested, converts first
  4. Calculates required scale factor to hit target size
  5. Iteratively resizes until under target (binary search approach)
  6. Reports final dimensions and size

Note: Uses decimal MB (1 MB = 1,000,000 bytes) to match Finder.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.