Loading... ## 前言 webp格式是Google推出的图片格式 这种格式可以无损压缩10%~30%的大小(实测有时可以压缩50%) 这样可以大大缩短网页加载速度 此篇文章是Linux安装教程 ## 正文 按顺序执行 ~~注意网络环境问题~~ ```bash sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev wget https://ajax.lug.ustc.edu.cn/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz tar -xzvf libwebp-1.1.0.tar.gz cd libwebp-1.1.0 ./configure make sudo make install echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib" >> ~/.bashrc ``` ## 使用方法 这个工具有`cwebp dwebp vwebp webpmux gif2webp`这几个常用命令 他们最常用的参数是`-q <float>` `<float>`填入`0-100`整数值 越大越图片质量越高 `-o <String>` `<String>`是输出文件名 ### cwebp 这个命令是`jpg jpeg png`等普通图片类型转换webp格式 使用方法 ```bash cwebp [options] input_file -o output_file.webp ``` ### dwebp 这个命令用于webp转`png jpg`格式 使用方法 ```bash dwebp [options] input_file.webp ``` 这个命令不能用`-q` ### vwebp 查看webp图片 使用方法 ```bash vwebp [options] input_file.webp ``` 这个命令不能用`-q -o` ### webpmux 嚯,这个命令厉害了 可以制作webp动画和提取动画的每一帧 ### gif2webp 这个命令用于将`gif`格式转换成`webp`动画格式 使用方法 ```bash gif2webp [options] input_file.gif -o output_file.webp ``` ## 后记 [官方文档][3] [1]: https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz [2]: https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html [3]: https://developers.google.com/speed/webp/docs/compiling#building Last modification:August 21, 2022 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 大哥给点钱吧~ヽ(・ω・´メ)(微信 支付宝 QQ都是一个码哦~