Skip to content

Introduction

imgsqz is a fast command-line tool for compressing images and converting between formats. It wraps the excellent sharp library (built on libvips) behind a single, memorable command with sensible defaults.

Terminal window
imgsqz photo.png # → optimized JPG next to the source
imgsqz hero.jpg -f webp # → WebP at quality 80
imgsqz *.png -f avif -q 50 # → batch-convert a folder to AVIF
  • Compresses JPG, PNG, WebP, AVIF and TIFF with quality you control.
  • Converts between any of those formats in one step.
  • Resizes by width and/or height with five fit modes.
  • Batches over many files (and globs) in a single invocation.
  • Reports the before/after size and percentage saved for every file.
  • Protects your originals — it refuses to overwrite the source unless you explicitly pass --replace.

It is also not a watcher, a build plugin, or a service. It does one job — take image files in, write optimized image files out — and exits.

Shipping web assets

Shrink hero images and convert to WebP/AVIF before deploying a site.

Cleaning up screenshots

Turn multi-megabyte PNG screenshots into compact JPGs for docs and issues.

Prepping uploads

Resize and compress a folder of photos before sending or archiving them.

CI pipelines

Add a deterministic, scriptable optimization step that fails loudly.

Commandimgsqz
Installnpm install -g @wdalhaj/imgsqz
Run without installingnpx @wdalhaj/imgsqz <input>
Input formatsAnything sharp can read (JPG, PNG, WebP, AVIF, TIFF, GIF, SVG, …)
Output formatsjpg · png · webp · avif · tiff
RuntimeNode.js 18+
Enginesharp ^0.33 (libvips)
LicenseMIT

Ready? Head to Installation.