[新软件] 跨平台客户端图片批量压缩工具 Squoosh

Summary

  • https://squoosh.app/ 本身是支持在线拖放之后压缩的
  • 这个工具是客户端,支持批量
  • https://github.com/GoogleChromeLabs/squoosh/tree/dev/cli

介绍

# 下载node.js(自动安装npm)
https://nodejs.org/zh-cn/download/
# 安装 squoosh
npm i -g @squoosh/cli

# 使用mozjpeg自动模式,并把输出放到当前目录的output子目录
cd /target_dir
squoosh-cli --mozjpeg auto ./ --output-dir ./output

# 使用网页上面生成的配置
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
Usage: squoosh-cli [options] <files...>

Options:
  -V, --version                                          output the version number
  -d, --output-dir <dir>                                 Output directory (default: ".")
  -s, --suffix <suffix>                                  Append suffix to output files (default: "")
  --max-optimizer-rounds <rounds>                        Maximum number of compressions to use for auto optimizations (default: "6")
  --optimizer-butteraugli-target <butteraugli distance>  Target Butteraugli distance for auto optimizer (default: "1.4")
  --resize [config]                                      Resize the image before compressing
  --quant [config]                                       Reduce the number of colors used (aka. paletting)
  --rotate [config]                                      Rotate image
  --mozjpeg [config]                                     Use MozJPEG to generate a .jpg file with the given configuration
  --webp [config]                                        Use WebP to generate a .webp file with the given configuration
  --avif [config]                                        Use AVIF to generate a .avif file with the given configuration
  --jxl [config]                                         Use JPEG-XL to generate a .jxl file with the given configuration
  --wp2 [config]                                         Use WebP2 to generate a .wp2 file with the given configuration
  --oxipng [config]                                      Use OxiPNG to generate a .png file with the given configuration
  -h, --help                                             display help for command

Leave a Reply