Squoosh CLI can run all the codecs you know from the Squoosh web app on your command line.
449
The Dockerized squoosh-cli: An adaptation of the renowned Google Squoosh tool in a Docker container. This containerized version brings the power and flexibility of Squoosh to your development environment with ease. Enjoy efficient image optimization and manipulation, all within a convenient Docker package.
https://hub.docker.com/r/willh/squoosh-cli
docker pull willh/squoosh-cli
Support wildcard filename handling
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli --webp '{}' -d images_output *.png *.jpg
Support directory handling
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli --webp '{}' -d images_output images
The following examples are compatible with the PowerShell & Bash as the main shell environment. Don't use Command Prompt on Windows.
Show help manual
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli -h
Use WebP to generate a .webp file with the given configuration
Compress image to WebP format with 80% quality, output result to out/ folder.
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli --webp '{quality:80}' -d 'out' SNAG-0060.png
Use OxiPNG to generate a .png file with the given configuration
Compress image to OxiPNG format, without the -d argument will replace it's original image.
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli --oxipng '{}' SNAG-0060.png
Note: pass
{}means using the default options
Use MozJPEG to generate a .jpg file with the given configuration
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli --mozjpeg '{quality:80}' -d 'out' SNAG-0066.png SNAG-0068.png
Use AVIF to generate a .avif file with the given configuration
The command supports wildcard character *:
docker run --rm -it -v ${PWD}:/data willh/squoosh-cli --mozjpeg '{quality:80}' -d 'out' SNAG-*.png
Usage: squoosh-cli [options] <files...>
Options:
-d, --output-dir <dir> Output directory (default: ".")
-s, --suffix <suffix> Append suffix to output files (default: "")
--max-optimizer-rounds <rounds> Maximum number of compressions to use for auto optimizations (default: "6")
--optimizer-butteraugli-target <butteraugli distance> Target Butteraugli distance for auto optimizer (default: "1.4")
--resize [config] Resize the image before compressing
--quant [config] Reduce the number of colors used (aka. paletting)
--rotate [config] Rotate image
--mozjpeg [config] Use MozJPEG to generate a .jpg file with the given configuration
--webp [config] Use WebP to generate a .webp file with the given configuration
--avif [config] Use AVIF to generate a .avif file with the given configuration
--jxl [config] Use JPEG-XL to generate a .jxl file with the given configuration
--wp2 [config] Use WebP2 to generate a .wp2 file with the given configuration
--oxipng [config] Use OxiPNG to generate a .png file with the given configuration
-h, --help display help for command
Note that the Squoosh CLI project project is no longer maintained by Google.
All available CLI config options can be found here: codecs.ts
It because the source code of the @squoosh/cli and @squoosh/lib has been removed from the squoosh repository. I made a fork to host all the last minute source code of the CLI in my GitHub repo.
MozJPEG (--mozjpeg [config])
{
quality: 75,
baseline: false,
arithmetic: false,
progressive: true,
optimize_coding: true,
smoothing: 0,
color_space: MozJpegColorSpace.YCbCr,
quant_table: 3,
trellis_multipass: false,
trellis_opt_zero: false,
trellis_opt_table: false,
trellis_loops: 1,
auto_subsample: true,
chroma_subsample: 2,
separate_chroma_quality: false,
chroma_quality: 75,
}
WebP (--webp [config])
{
quality: 75,
target_size: 0,
target_PSNR: 0,
method: 4,
sns_strength: 50,
filter_strength: 60,
filter_sharpness: 0,
filter_type: 1,
partitions: 0,
segments: 4,
pass: 1,
show_compressed: 0,
preprocessing: 0,
autofilter: 0,
partition_limit: 0,
alpha_compression: 1,
alpha_filtering: 1,
alpha_quality: 100,
lossless: 0,
exact: 0,
image_hint: 0,
emulate_jpeg_size: 0,
thread_level: 0,
low_memory: 0,
near_lossless: 100,
use_delta_palette: 0,
use_sharp_yuv: 0,
}
AVIF (--avif [config])
{
cqLevel: 33,
cqAlphaLevel: -1,
denoiseLevel: 0,
tileColsLog2: 0,
tileRowsLog2: 0,
speed: 6,
subsample: 1,
chromaDeltaQ: false,
sharpness: 0,
tune: AVIFTune.auto,
}
JPEG-XL (--jxl [config])
{
effort: 7,
quality: 75,
progressive: false,
epf: -1,
lossyPalette: false,
decodingSpeedTier: 0,
photonNoiseIso: 0,
lossyModular: false,
}
WebP2 (--wp2 [config])
{
quality: 75,
alpha_quality: 75,
effort: 5,
pass: 1,
sns: 50,
uv_mode: UVMode.UVModeAuto,
csp_type: Csp.kYCoCg,
error_diffusion: 0,
use_random_matrix: false,
}
OxiPNG (--oxipng [config])
{
level: 2
}
Rotate (--rotate [config])
{
numRotations: 0
}
Possible values:
1for 90 degree,2for 180 degree, ...etc.
Resize (--resize [config])
{
width: number,
height: number,
method: 'triangle' | 'catrom' | 'mitchell' | 'lanczos3',
premultiply: true,
linearRGB: true,
}
Quantize (--quant [config])
{
numColors: 256,
dither: 1.0,
}
Content type
Image
Digest
sha256:d039c5c06…
Size
40.1 MB
Last updated
almost 3 years ago
docker pull willh/squoosh-cli