2

I hear that mozjpeg is a nice jpeg compressor from Mozilla. How can I convert my folder with *.tiff to jpg from terminal using mozjpeg?

A.B.
  • 89,123
  • 21
  • 245
  • 323
Vitaly Zdanevich
  • 1,094
  • 4
  • 19
  • 39

2 Answers2

4

You will have to build mozjpeg from source.

If you do have the packages to compile it, you can install it with the following command:

sudo apt-get install autoconf automake libtool nasm make pkg-config git
  • Fetch the source code with:

    git clone https://github.com/mozilla/mozjpeg.git
    
  • Build it with:

    cd mozjpeg
    autoreconf -fiv
    ./configure --prefix=/usr
    make
    

You will have 2 options: to install with the command:

make install

or to create a "deb" (that you then can use to install) with:

make deb

But it does not seem to support "tiff". So you need to extract the files 1st. See How to convert TIFF scan file to JPEG or PNG general file format in Ubuntu? for that.

This is a generic command to compress a jpg to 75%:

convert filename1.jpg pnm:- | cjpeg -quality 75 > filename2.jpg

The jpegtran tool can be used to optimise an image:

jpegtran -outfile filename1.jpg -optimise -copy none filename2.jpg

If you get any errors please edit your question and I'll have a look.

Rinzwind
  • 293,910
  • 41
  • 570
  • 710
1

I have checked all man-pages

/usr/share/man/man1/djpeg.1
/usr/share/man/man1/cjpeg.1
/usr/share/man/man1/jpegtran.1
/usr/share/man/man1/wrjpgcom.1
/usr/share/man/man1/rdjpgcom.1

but I think I have to disappoint you. You can't convert images from TIFF to JPEG with any of these programs.


After the installation with the steps described in Rinzwind answer I have installed the deb. The following files are installed:

Output of dpkg -L mozjpeg

/.
/usr
/usr/bin
/usr/bin/cjpeg
/usr/bin/djpeg
/usr/bin/rdjpgcom
/usr/bin/tjbench
/usr/bin/wrjpgcom
/usr/bin/jpegtran
/usr/lib
/usr/lib/libjpeg.so.62.2.0
/usr/lib/libturbojpeg.a
/usr/lib/libturbojpeg.so.0.1.0
/usr/lib/libjpeg.a
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/djpeg.1
/usr/share/man/man1/cjpeg.1
/usr/share/man/man1/jpegtran.1
/usr/share/man/man1/wrjpgcom.1
/usr/share/man/man1/rdjpgcom.1
/usr/share/doc
/usr/share/doc/mozjpeg-3.1
/usr/share/doc/mozjpeg-3.1/wizard.txt
/usr/share/doc/mozjpeg-3.1/usage.txt
/usr/share/doc/mozjpeg-3.1/libjpeg.txt
/usr/share/doc/mozjpeg-3.1/structure.txt
/usr/share/doc/mozjpeg-3.1/README
/usr/share/doc/mozjpeg-3.1/README-turbo.txt
/usr/share/doc/mozjpeg-3.1/README-mozilla.txt
/usr/share/doc/mozjpeg-3.1/example.c
/usr/include
/usr/include/jconfig.h
/usr/include/turbojpeg.h
/usr/include/jmorecfg.h
/usr/include/jerror.h
/usr/include/jpeglib.h
/usr/lib/libjpeg.so
/usr/lib/libturbojpeg.so
/usr/lib/libjpeg.so.62
/usr/lib/libturbojpeg.so.0
A.B.
  • 89,123
  • 21
  • 245
  • 323