此篇雖然講 png,不過其它格式(jpg) 也都是一樣語法~
webp:Linux 如何將 png 轉 webp
Linux webp 工具程式安裝
- sudo apt install webp
webp 有安裝這些工具:
- cwebp: compress an image file to a WebP file
- dwebp: decompress a WebP file to an image file
- gif2webp: Convert a GIF image to WebP
- img2webp: create animated WebP file from a sequence of input images.
- vwebp: decompress a WebP file and display it in a window
- webpinfo: print out the chunk level structure of WebP files along with basic integrity checks.
- webpmux: create animated WebP files from non-animated WebP images, extract frames from animated WebP images, and manage XMP/EXIF metadata and ICC profile.
主要會使用的是 cwebp,語法如下:
- cwebp -q 90 source.png -o result.webp
- q 是 quality,最佳是100,預設值是75
多個檔案(jpg)轉檔,可用下述 Shell
- for i in *.jpg; do cwebp -q 90 "$i" -o "${i%.jpg}.webp"; done