[CentOS 7] コマンドで PNG ファイルを圧縮できる optipng を yum でインストールした方法
yum で一発でインストールできました。
$ cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) $ which optipng /usr/bin/which: no optipng in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/nobi/.local/bin:/home/nobi/bin) $ yum search optipng 読み込んだプラグイン:fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Determining fastest mirrors * base: ftp.riken.jp * epel: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp ================================================================ N/S matched: optipng ================================================================= optipng.x86_64 : PNG optimizer and converter Name and summary matches only, use "search all" for everything. $ sudo yum install optipng [sudo] password for nobi: 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * epel: mirror.dmmlabs.jp * extras: ftp.tsukuba.wide.ad.jp * updates: ftp.tsukuba.wide.ad.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ optipng.x86_64 0:0.7.4-4.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ======================================================================================================================================================= Package アーキテクチャー バージョン リポジトリー 容量 ======================================================================================================================================================= インストール中: optipng x86_64 0.7.4-4.el7 base 85 k トランザクションの要約 ======================================================================================================================================================= インストール 1 パッケージ 総ダウンロード容量: 85 k インストール容量: 178 k Is this ok [y/d/N]: y Downloading packages: optipng-0.7.4-4.el7.x86_64.rpm | 85 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : optipng-0.7.4-4.el7.x86_64 1/1 検証中 : optipng-0.7.4-4.el7.x86_64 1/1 インストール: optipng.x86_64 0:0.7.4-4.el7 完了しました! $ which optipng /usr/bin/optipng $
以上。
optipng のヘルプを表示させてみると、
$ optipng -h
Synopsis:
optipng [options] files ...
Files:
Image files of type: PNG, BMP, GIF, PNM or TIFF
Basic options:
-?, -h, -help show this help
-o optimization level (0-7) [default: 2]
-v run in verbose mode / show copyright and version info
General options:
-backup, -keep keep a backup of the modified files
-clobber overwrite existing files
-fix enable error recovery
-force enforce writing of a new output file
-preserve preserve file attributes if possible
-quiet, -silent run in quiet mode
-simulate run in simulation mode
-out write output file to
-dir write output file(s) to
-log log messages to
-- stop option switch parsing
Optimization options:
-f PNG delta filters (0-5) [default: 0,5]
-i PNG interlace type (0-1)
-zc zlib compression levels (1-9) [default: 9]
-zm zlib memory levels (1-9) [default: 8]
-zs zlib compression strategies (0-3) [default: 0-3]
-zw zlib window size (256,512,1k,2k,4k,8k,16k,32k)
-full produce a full report on IDAT (might reduce speed)
-nb no bit depth reduction
-nc no color type reduction
-np no palette reduction
-nx no reductions
-nz no IDAT recoding
Editing options:
-snip cut one image out of multi-image or animation files
-strip strip metadata objects (e.g. "all")
Optimization levels:
-o0 <=> -o1 -nx -nz (0 or 1 trials)
-o1 <=> -zc9 -zm8 -zs0 -f0 (1 trial)
(or...) -zc9 -zm8 -zs1 -f5 (1 trial)
-o2 <=> -zc9 -zm8 -zs0-3 -f0,5 (8 trials)
-o3 <=> -zc9 -zm8-9 -zs0-3 -f0,5 (16 trials)
-o4 <=> -zc9 -zm8 -zs0-3 -f0-5 (24 trials)
-o5 <=> -zc9 -zm8-9 -zs0-3 -f0-5 (48 trials)
-o6 <=> -zc1-9 -zm8 -zs0-3 -f0-5 (120 trials)
-o7 <=> -zc1-9 -zm8-9 -zs0-3 -f0-5 (240 trials)
-o7 -zm1-9 <=> -zc1-9 -zm1-9 -zs0-3 -f0-5 (1080 trials)
Notes:
The combination for -o1 is chosen heuristically.
Exhaustive combinations such as "-o7 -zm1-9" are not generally recommended.
Examples:
optipng file.png (default speed)
optipng -o5 file.png (slow)
optipng -o7 file.png (very slow)
$
いっぱい表示されました。