上一篇遷移post中提到新版的500px.com全部使用webp的圖片格式,這個是在瀏覽器中可以打開的校辩,但是Windows默認不支持的,好像之前iMac也不能識別。盡管webp有很多優(yōu)勢读规,但是jpeg/png的地位還是撼動不了的。
Windows 上可以裝一個插件燃少,使用“Windows Photo Viewer”打開束亏,現(xiàn)在有Ubuntu on Windows了方便了好多,可以直接使用命令行來完成阵具,相當高效碍遍。
安裝使用webp
下載
- 訪問 https://developers.google.com/speed/webp/download 下載對應的系統(tǒng)版本
- 這里有64位的 downloads.webmproject.org/releases/webp/index.html
解壓
這里我選擇在Ubuntu on Windows 上使用,所以下載了linux版本
$ wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.0-rc3-linux-x86-64.tar.gz
$ ls -la libwebp-0.6.0-rc3-linux-x86-64.tar.gz
$ tar -zxf $_
$ cd libwebp-0.6.0-rc3-linux-x86-64/
~/libwebp-0.6.0-rc3-linux-x86-64
$ ls
bin doc include lib README README.mux
~/libwebp-0.6.0-rc3-linux-x86-64
$ ls -R
.:
bin doc include lib README README.mux
./bin:
anim_diff cwebp dwebp gif2webp img2webp vwebp webpmux
./doc:
cwebp.html dwebp.html gif2webp.html img2webp.html vwebp.html webpmux.html
cwebp.txt dwebp.txt gif2webp.txt img2webp.txt vwebp.txt webpmux.txt
./include:
webp
./include/webp:
decode.h demux.h encode.h mux.h mux_types.h types.h
./lib:
libwebp.a libwebpdemux.a libwebpmux.a
$ cd ..
$ mv libwebp-0.6.0-rc3-linux-x86-64 .local/libwebp-0.6.0
配置
# add to shell configuration file in your home dir
# bash .bashrc/.bash_profile
# zsh .zshrc
# csh .cshrc
# fish .fishrc等等
PATH=/home/xxx/.loca/libwebp-0.6.0/bin:$PATH
source ~/SHELLCONFIGURATIPNFILE
使用
- cwebp encodes images in either JPEG, PNG or TIFF format into WebP阳液;
- dwebp decodes images in WebP format into PNG怕敬;
$ cwebp -q 80 image.png -o image.webp
$ dwebp image.webp -o image.png
此外
# Ubuntu:
sudo apt install webp
Reference
- 我的另外一篇post How to convert webp to png/jpg/gif in MacOS