image optimize
Support multi process for image, such as: resize, gray, crop, watermark and optimize.
Installation
Shell script (Linux / macOS)
|
Install a specific version or to a custom directory:
# Specific version
|
# Custom install directory
| INSTALL_DIR=/.local/bin
Pre-built binary
Download the archive for your platform from GitHub Releases, extract and place the binary in your PATH.
| Platform | Archive |
|---|---|
| macOS Apple Silicon | imageoptimize-darwin-aarch64.tar.gz |
| macOS Intel | imageoptimize-darwin-x86_64.tar.gz |
| Linux x86_64 (musl) | imageoptimize-linux-musl-x86_64.tar.gz |
| Linux aarch64 (musl) | imageoptimize-linux-musl-aarch64.tar.gz |
| Windows x86_64 | imageoptimize-windows.exe.zip |
Build from source
Usage
imageoptimize [OPTIONS] <SOURCE>
<SOURCE> is the root directory to scan. The tool recurses through it and processes all matching images.
Options
| Option | Default | Description |
|---|---|---|
-s, --source <DIR> |
— | Source directory (alternative to positional arg) |
--output <DIR> |
— | Output directory (required unless --overwrite) |
-o, --overwrite |
false | Write optimized files back to the source directory |
-f, --format <FMT> |
jpeg,jpg,png | Only process these formats (jpeg, jpg, png) |
--convert <CONV> |
all four | Format conversions to generate (jpeg-avif, jpeg-webp, png-avif, png-webp, disable) |
--jpeg-quality <N> |
80 | JPEG encode quality (0–100) |
--png-quality <N> |
90 | PNG encode quality (0–100) |
--avif-quality <N> |
80 | AVIF encode quality (0–100) |
--webp-quality <N> |
80 | WebP encode quality (0–99 lossy, ≥100 lossless) |
Examples
Optimize in place — overwrite originals with smaller files:
Optimize to a separate directory — keeps originals untouched and also generates AVIF/WebP variants:
Process only JPEG files:
Generate AVIF variants only (skip WebP):
Disable format conversion (optimize originals only, no AVIF/WebP):
Custom quality:
Output
Each processed file prints a one-line summary:
path/to/image.avif: 42kb 68%(0.12) 320ms
Fields: output path · file size · size relative to original · dssim perceptual difference · elapsed time.
License
This project is licensed under the Apache License 2.0 license.