What this is
Squoosh has unfortunately discontinued the CLI tool and the CLI command
generator. This fork combines the original CLI changes with the latest
updates.
This means you can now enjoy the original experience with the new features:
Where to get the CLI tool
Please see
this page
for installation instructions. You can run this package either via
npx
, or install it using
npm -g
.
Example usage
First, install the tool
from here.
Choose the settings you want, then click the CLI button
(
).
Pay close attention to the message at the bottom; some codecs (such as
Browser JPEG) can't be used from the commandline, though codecs such as
MozJPEG and OxiPNG, can be. If your codec is supported, the needed command
will be stored in your clipboard.
The commands generated can be quite lengthy. For the sake of example, we'll
use this auto-generated OxiPNG example:
npx @frostoven/squoosh-cli --oxipng '{"level":2,"interlace":false}'
If you installed the command globally with
npm -g
, then you'll need to
replace the starting part of the command. In our example case, like so:
squoosh-cli --oxipng '{"level":2,"interlace":false}'
Note that the example commands exclude the file name; you'll need to add
that yourself, as shown below.
Now, open your favorite terminal. Paste the generated CLI command, and then
add the name of the file you wish to optimize:
squoosh-cli --oxipng '{"level":2,"interlace":false}' my_file.jpg
You should get something like this:
$ squoosh-cli --oxipng '{"level":2,"interlace":false}' my_file.jpg
0/1 ⠏ ▐▨▨▨▨▨╌╌╌╌╌▌ Encoding (16 threads)
1/1 ✔ Squoosh results:
my_file.jpg: 522.57KB
└ my_file.png → 460.10KB (88.0%)
This should go without saying, but some codecs can actually make a file
larger after conversion (especially when re-encoding a lossy file into
lossless), so be sure you understand what each
file format
is trying to
achieve.
Caveats
This project specifically aims to retain original CLI functionality.
Brand-new and experimental codecs will not immediately have CLI support, but
receive support in future as things progress.