jpegotim壓縮jpg圖片
安裝jpegotim
如果你有epel yum源,使用如下命令即可
復制代碼代碼如下:
# yum install jpegoptim
壓縮圖片命令
復制代碼代碼如下:
# jpegoptim ttlsa.jpg
ttlsa.jpg 1425x823 24bit N JFIF [OK] 1074449 --> 853514 bytes (20.56%), optimized.
可以看到ttlsa.jpg自動被壓縮了20.56%。
再壓縮一次
復制代碼代碼如下:
# jpegoptim ttlsa.jpg
ttlsa.jpg 1425x823 24bit N JFIF [OK] 853514 --> 853514 bytes (0.00%), skipped.
圖片已經被壓縮過了,所以提示跳過,不需要在被壓縮。
提供一個批量壓縮的腳本
復制代碼代碼如下:
for i in /data/site/image.ttlsa.com/images/*.jpg; do jpegoptim $i; done
pngcrush優化PNG圖片
項目地址:http://pmt.sourceforge.net/pngcrush/
復制代碼代碼如下:
# wget http://downloads.sourceforge.net/project/pmt/pngcrush/1.7.88/pngcrush-1.7.88.tar.gz
# tar -xzvf pngcrush-1.7.88.tar.gz
# cd pngcrush-1.7.88
# make
# cp pngcrush /usr/bin
pngcrush使用語法
復制代碼代碼如下:
usage: pngcrush [options except for -e -d] infile.png outfile.png
pngcrush -e ext [other options] file.png ...
pngcrush -d dir/ [other options] file.png ...
pngcrush -ow [other options] file.png [tempfile.png]
pngcrush -n -v file.png ...
options:
-bail (bail out of trial when size exceeds best size found
-bit_depth depth (deprecated)
-blacken (zero samples underlying fully-transparent pixels)
-brute (use brute-force: try 148 different methods)
........更多內容請自己看幫助......
pngcrush簡單命令
復制代碼代碼如下:
pngcrush -brute -e "myimage_compressed.png" myimage.png
.........省略.....
Best pngcrush method = 123 (ws 15 fm 4 zl 9 zs 1) = 124820
for output to ttlsattlsa_new.png
(1.63% critical chunk reduction)
(1.63% filesize reduction)
CPU time decoding 1.560, encoding 7.640, other 0.030, total 9.230 sec.
批量優化PNG圖片
復制代碼代碼如下:
pngcrush -brute -d "/data/site/image.ttlsa.com/images" *.png