LoginSignup
15
14

More than 5 years have passed since last update.

Mozilla 製 JPEG エンコーダー「mozjpeg」

Last updated at Posted at 2017-03-18

Mozilla JPEG Encoder Project

オンラインツール

https://mozjpeg.codelove.de/
2MB まで。

インストール

CentOS 7.3.1611 へのインストール手順。

curl -LO https://github.com/mozilla/mozjpeg/releases/download/v3.2-pre/mozjpeg-3.2-release-source.tar.gz
tar xf mozjpeg-3.2-release-source.tar.gz
cd mozjpeg
yum install automake gcc nasm
./configure && make && make install

/opt/mozjpeg にインストールされる。

シンボリックリンク

ln -s /opt/mozjpeg/bin/* /usr/local/bin
ln -s /opt/mozjpeg/share/man/man1/* /usr/local/share/man/man1

コマンド名は libjpeg を踏襲しているので、既に libjpeg や libjpeg-turbo がインストールされている場合は注意。

テスト

画像処理界隈で有名な Lena の画像。1

Lena (remastered)

cjpeg -optimize -quality 90 lena.jpg > lena_90.jpg

-quality 未指定の場合のデフォルト値は 75 。
-optimize オプションはファイルサイズを小さくする可能性があるが、メモリの使用量が増え、処理に時間がかかる。画像の品質と圧縮解除速度は影響を受けない。

quality サイズ 時間 圧縮率
84 49451 0.073s 17.5%
90 60599 0.079s 21.5%
95 80572 0.111s 28.6%
100 173504 0.214s 61.5%

コマンド

https://github.com/mozilla/mozjpeg/blob/master/usage.txt
jpegtran がロスレス圧縮で、cjpeg が非可逆圧縮のコマンド。

cjpeg

compress an image file to a JPEG file

cjpeg [ options ] [ filename ]

djpeg

decompress a JPEG file to an image file

djpeg [ options ] [ filename ]

jpegtran

lossless transformation of JPEG files

jpegtran [ options ] [ filename ]

rdjpgcom

display text comments from a JPEG file

rdjpgcom [ -raw ] [ -verbose ] [ filename ]

wrjpgcom

insert text comments into a JPEG file

wrjpgcom [ -replace ] [ -comment text ] [ -cfile name ] [ filename ]
15
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14