Install MozJpeg encoder with Ubuntu 20.4

    MOZjpeg is a very interesting fork of turbojpeg, it saves on average 10-15% compared to a normal jpeg without losing backward compatibility. Its disadvantage is the time it takes to be encoded (x2.5) and that it lacks the alpha channel that new-gen formats like avif and webp have.

    A good explanation about the differences of jpeg-turbo with MOZjpeg and some testing comparations could be found here https://libjpeg-turbo.org/About/Mozjpeg.

    Below the steps to compile the encoder/decoder alongside Ubuntu 20.04, if you have any doubts or comments leave them here below, i love to hear your through about.


    Install Compiler Tools

    sudo apt-get update && sudo apt-get upgrade
    sudo apt-get install cmake autoconf automake libtool nasm make pkg-config

    download and install MOZjpeg from source

    wget https://github.com/mozilla/mozjpeg/archive/refs/tags/v4.0.3.tar.gz -O mozjpeg-master.tar.gz
    tar xvzf mozjpeg-master.tar.gz
    cd mozjpeg-master/
    mkdir build && cd build
    sudo cmake -G"Unix Makefiles" -DPNG_SUPPORTED=ON ../
    sudo make install
    sudo make deb
    sudo dpkg -i mozjpeg_4.0.3_amd64.deb
    sudo ln -s /opt/mozjpeg/bin/cjpeg /usr/bin/mozjpeg
    sudo ln -s /opt/mozjpeg/bin/jpegtran /usr/bin/mozjpegtran
    

    give a try with mozjpeg -h:

    mozjpeg -h


    the standard jpg has been converterted with:
    convert -quality 85 kodim04.png kodim04.jpg
    the MOZjpg has been converterted with:
    cjpeg -quality 77 -nojfif -tune-ssim kodim04.png > kodim04.moz.jpg

    Post navigation

    You might be interested in...

    3 responses to Install MozJpeg encoder with Ubuntu 20.4

    1. the “apt update” and “apt upgrade” in the first codeblock should be switched. Running first “upgrade” and then “update” afterwards is not that useful 😀

    Comments

    Your email address will not be published. Required fields are marked *