sharp-cli

raw JSON →
5.2.0 verified Sat Apr 25 auth: no javascript

sharp-cli is a command-line interface for the sharp library, a high-performance Node.js image processing module that uses libvips. Version 5.2.0 supports conversion and manipulation of JPEG, PNG, WebP, AVIF, TIFF, GIF, and SVG images. It provides commands for resizing, cropping, rotating, blurring, compositing, and other common image operations. The CLI mirrors most sharp API features, including input options like auto-orient and output options like smart-deblock. It follows sharp's release cadence and requires Node.js >= 18.17. Compared to alternatives like ImageMagick or GraphicsMagick, sharp-cli leverages libvips for speed and memory efficiency, with a focused, modern command set.

error Error: Input file is required
cause No input file provided to sharp command
fix
Specify an input image file as the first argument, e.g., sharp input.jpg resize 300 200 output.jpg
error Command not found: sharp
cause sharp-cli not installed globally or npx not used
fix
Install globally: npm install -g sharp-cli, or use npx sharp
error Error: Unknown argument: --resize 300
cause Incorrect argument syntax for resize command
fix
Use: sharp resize <width> <height>, e.g., sharp input.jpg resize 300 200 output.jpg
breaking Node.js version requirement increased to 18.17+ in v5.0.0
fix Update Node.js to version 18.17 or later.
breaking In v4.0.0, --band was renamed to --channel for extractChannel command
fix Use --channel instead of --band.
gotcha If sharp-cli is not installed globally, commands must be prefixed with npx
fix Install globally with npm install -g sharp-cli or use npx sharp.
breaking v3.0.0 dropped support for Node.js < 14.15
fix Upgrade Node.js to at least 14.15.
deprecated --withMetadata input option renamed to --metadata in v4.1.0
fix Use --metadata instead of --withMetadata.
npm install sharp-cli
yarn add sharp-cli
pnpm add sharp-cli

Resize an image to 300x200, rotate 90 degrees and convert to WebP, and extract a region from a TIFF.

npx sharp-cli input.jpg resize 300 200 -o output.jpg
npx sharp-cli input.png --rotate 90 --format webp -o rotated.webp
npx sharp-cli input.tif --resize 800 600 --extract 50 50 200 200 output.png