Description
Squoosh is an image compression web app that reduces image sizes through numerous formats.[1]
Squoosh can be used via API or CLI to compress many images at once.
Squoosh CLI
Squoosh CLI is an experimental way to run all the codecs from the Squoosh web app via command line using WebAssembly.
The Squoosh CLI uses a worker pool to parallelize processing images. This way you can apply the same codec to many images at once.
Note: Squoosh CLI is currently not the fastest image compression tool in town and doesn’t aim to be. It is, however, fast enough to compress many images sufficiently quick at once.
Installation
The Squoosh CLI can be used straight from the command line without installing using npx:
1 | $ npx @squoosh/cli <options...> |
You can also install the Squoosh CLI:
1 | $ npm i -g @squoosh/cli |
Example Usage
1 | npx @squoosh/cli --mozjpeg auto source-directory/ace.jpg -d output-directory/ |
This example will take a jpg file input, apply compression, and output a jpg file to the specified directory.
Excample Script
1 | #!/bin/bash |