


当サイトで記事に使用している画像形式はpngです。
下記サイトでスピードを調べていますがpng画像の最適化のアドバイスが表示されていました。
GTmetrix – Analyze your site’s speed and make it faster.
https://gtmetrix.com/
評価はEグレードで、これは頑張ってみるかってことでpng画像の最適化を実行しました。
参考サイト
PNG画像を最適化するツール「OptiPNG」
http://www.koikikukan.com/archives/2013/10/31-005555.php
最適化ツールはOptiPNGでyumでインストールできるんですね。
OptiPNG: Advanced PNG Optimizer
http://optipng.sourceforge.net/
- OptiPNG インストール
- 最適化
- 一括最適化
OSはCentOS 7です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# yum install optipng (snip) Running transaction Installing : optipng-0.7.4-4.el7.x86_64 1/1 Verifying : optipng-0.7.4-4.el7.x86_64 1/1 Installed: optipng.x86_64 0:0.7.4-4.el7 Complete! # yum info optipng Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Installed Packages Name : optipng Arch : x86_64 Version : 0.7.4 Release : 4.el7 Size : 178 k Repo : installed From repo : base Summary : PNG optimizer and converter URL : http://optipng.sourceforge.net/ License : zlib Description : OptiPNG is a PNG optimizer that recompresses image files to a smaller size, : without losing any information. This program also converts external formats : (BMP, GIF, PNM and TIFF) to optimized PNG, and performs PNG integrity checks : and corrections. |
取り敢えずサイトで使用しているCentOSアイコン画像を最適化してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# optipng CentOS.png ** Processing: CentOS.png 199x52 pixels, 4x8 bits/pixel, RGB+alpha Reducing image to 3x8 bits/pixel, RGB Input IDAT size = 12777 bytes Input file size = 12884 bytes Trying: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 10366 zc = 9 zm = 8 zs = 0 f = 5 IDAT size = 10059 Selecting parameters: zc = 9 zm = 8 zs = 0 f = 5 IDAT size = 10059 Output IDAT size = 10059 bytes (2718 bytes decrease) Output file size = 10166 bytes (2718 bytes = 21.10% decrease) |
21.10%減少しました。
サイトのpng画像を一括で最適化してみます。
サイトのトップをカレントにして実行します。全部で11,673ありました。
1 2 |
[root@host html]# find . -name "*.png" | wc -l 11673 |
1 |
[root@host html]# find . -name "*.png" -print | xargs optipng |
再度スピードテストを実行してみます。png画像の最適化のアドバイスは綺麗に無くなりました。
定期的にcronで実行した方がいいかもしれません。