2017-03-10 21:44:12 +01:00
|
|
|
mozjpeg (Mozilla JPEG Encoder Project)
|
2014-10-18 00:42:47 +02:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
mozjpeg is a fork of libjpeg-turbo from Mozilla Research. Its
|
|
|
|
goal is to reduce the size of JPEG files without reducing quality
|
|
|
|
or compatibility with the vast majority of the world's deployed
|
|
|
|
decoders. The idea is to reduce transfer times for JPEGs on the Web,
|
|
|
|
thus reducing page load times.
|
|
|
|
|
|
|
|
mozjpeg is not intended to be a general JPEG library replacement. It
|
|
|
|
makes tradeoffs that are intended to benefit Web use cases and
|
|
|
|
focuses solely on improving encoding. It is best used as part of a Web
|
|
|
|
encoding workflow.
|
|
|
|
|
|
|
|
In essence, libjpeg-turbo (as shipped with Slackware) is optimized
|
|
|
|
for speed of encoding/decoding, while mozjpeg is optimized for
|
|
|
|
encoding smaller file sizes (at the expense of speed). mozjpeg will
|
|
|
|
not interfere with Slackware's libjpeg-turbo package, as it installs
|
|
|
|
to /opt/mozjpeg/.
|
2017-03-10 21:44:12 +01:00
|
|
|
|
|
|
|
mozjpeg supports multiple versions of the libjpeg API. By default,
|
|
|
|
version 6b is built. If you need compatibility with libjpeg 7 or 8,
|
|
|
|
set API=7 or API=8 in the script's environment.
|
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
To run the binaries, either call them by their full paths, e.g:
|
2017-03-10 21:44:12 +01:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
$ /opt/mozjpeg/bin/cjpeg
|
2017-03-10 21:44:12 +01:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
...or else:
|
2017-03-10 21:44:12 +01:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
$ source /etc/profile.d/mozjpeg.sh
|
2017-05-03 20:22:27 +02:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
...to temporarily make mozjpeg the default, in the current shell.
|
|
|
|
Running e.g. "cjpeg" will now run the mozjpeg one. If you wanted to
|
|
|
|
do this permanently for all users (not recommended), you could:
|
2017-05-03 20:22:27 +02:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
# chmod +x /etc/profile.d/mozjpeg.sh
|
2017-03-10 21:44:12 +01:00
|
|
|
|
2021-03-13 07:42:49 +01:00
|
|
|
...then log out and back in. The profile script isn't executable by
|
|
|
|
default, to avoid surprises.
|
|
|
|
|
|
|
|
Development
|
|
|
|
-----------
|
|
|
|
To compile & link with the mozjpeg libraries, use -I/opt/mozjpeg/include
|
|
|
|
and -L/opt/mozjpeg/lib (or lib64). You might also want -static, or
|
|
|
|
else -Wl,-rpath,/opt/mozjpeg/lib (or lib64). Starting with version 3.2,
|
|
|
|
there's also pkg-config support for mozjpeg. If you source the profile
|
|
|
|
script, software that uses pkg-config should find and link with the
|
|
|
|
mozjpeg libraries automatically.
|
|
|
|
|
|
|
|
Java Support
|
|
|
|
------------
|
|
|
|
Optionally, mozjpeg can be built with Java wrapper support
|
|
|
|
for turbojpeg. To do this, install one of: jdk, openjdk8,
|
|
|
|
openjdk7, or openjdk6 (or possibly one of the zulu-openjdk*
|
|
|
|
or adoptopenjdk* packages; untested). Then run this script with
|
|
|
|
JAVA=yes in the environment. The Java library will be installed
|
2017-03-10 21:44:12 +01:00
|
|
|
as /opt/mozjpeg/classes/turbojpeg.jar, and the docs will be in
|
|
|
|
/usr/doc/mozjpeg-$VERSION/javadoc.
|