Summary
- https://squoosh.app/ 本身是支持在线拖放之后压缩的
- 这个工具是客户端,支持批量
- https://github.com/GoogleChromeLabs/squoosh/tree/dev/cli
介绍
Shell
x
11
11
1
# 下载node.js(自动安装npm)
2
https://nodejs.org/zh-cn/download/
3
# 安装 squoosh
4
npm i -g @squoosh/cli
5
6
# 使用mozjpeg自动模式,并把输出放到当前目录的output子目录
7
cd /target_dir
8
squoosh-cli --mozjpeg auto ./ --output-dir ./output
9
10
# 使用网页上面生成的配置
11
npx @squoosh/cli --webp '{"quality":60,"target_size":0,"target_PSNR":0,"method":6,"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":52,"use_delta_palette":0,"use_sharp_yuv":0}' ./ --output-dir ./output

Shell
xxxxxxxxxx
1
19
19
1
Usage: squoosh-cli [options] <files...>
2
3
Options:
4
-V, --version output the version number
5
-d, --output-dir <dir> Output directory (default: ".")
6
-s, --suffix <suffix> Append suffix to output files (default: "")
7
--max-optimizer-rounds <rounds> Maximum number of compressions to use for auto optimizations (default: "6")
8
--optimizer-butteraugli-target <butteraugli distance> Target Butteraugli distance for auto optimizer (default: "1.4")
9
--resize [config] Resize the image before compressing
10
--quant [config] Reduce the number of colors used (aka. paletting)
11
--rotate [config] Rotate image
12
--mozjpeg [config] Use MozJPEG to generate a .jpg file with the given configuration
13
--webp [config] Use WebP to generate a .webp file with the given configuration
14
--avif [config] Use AVIF to generate a .avif file with the given configuration
15
--jxl [config] Use JPEG-XL to generate a .jxl file with the given configuration
16
--wp2 [config] Use WebP2 to generate a .wp2 file with the given configuration
17
--oxipng [config] Use OxiPNG to generate a .png file with the given configuration
18
-h, --help display help for command
19

