Coming up: 22 Sep - Vue Storefront 1 Advanced training

Yireo - Trainings & extensions

Open main menu

jpegoptim: Wrong JPEG library version

And now for something completely different: We are currently experimenting with image-optimization tools, to replicate the behaviour of remote services like PageSpeed and Smush.It. And for this we needed a tool called to be installed on the hosting level. However, starting up jpegoptim gave an error about the wrong JPEG library version. How to solve that?

Meet jpegoptim

The tool jpegoptim is one of many tools, that allow you to optimize, shrink and minimize images. Other tools include optipng, pngout, pngcrush and jpegtran. We wanted to install jpegoptim, which is fairly easy if you're familiar with UNIX source-compilation:

$ ./configure
$ make
$ make install

And voila, the source was compiled into usable binaries. Well, usable?

Starting up jpegoptim

Running jpegoptim from the command-line gave an error in our case:

$ jpegoptim
Wrong JPEG library version: library is 62, caller expects 80

Bummer. It's not easy as it should be. A search on the web found some reports about two versions of the libjpeg package, that jpegoptim depends on: Version 6 and version 8. On our server, version 6 (or actually 6.2) was installed, while jpegoptim required version 8.

We tried to recompile jpegoptim with some modifications to the configure, but this didn't go well. And spending hours on such a little tool is not worth the effort. So we went ahead for some more radical approaches.

Hacking our library links

To confirm that jpegoptim was using the wrong library-version, we ran ldd:

$ ldd /usr/local/bin/jpegoptim =>  (0x00007fff6b62a000) => /usr/lib64/ (0x00007fc953571000) => /lib64/ (0x00007fc9531de000)
    /lib64/ (0x00007fc95379c000)

Indeed, the second line contained a reference to the 6.2 version of libjpeg. So where is version 8?

$ locate

Two libraries, but on closer inspection, is just a symbolic link to Hmm, what if our which we don't want to use, actually refers to this new 8.4.0 version.

$ cp /usr/lib64/ /usr/lib64/
$ ln -sf /usr/local/lib/ /usr/lib64/
$ jpegoptim

It works. Ofcourse not in a very solid way, because any other tool that referred to the old library now also is forced to use the new 8.4.0 library. But with a little bit of luck, nobody will notice and hopefully the new library is backwards-compatible in full.

Another day of hacking at the office. 

Posted on 31 October 2012

Looking for a training in-house?

Let's get to it!

Do not miss out on what we say

This will be the most interesting spam you've ever read

We don't write too commercial stuff, we focus on the technology (which we love) and we regularly come up with innovative solutions. Via our newsletter, you can keep yourself up to date on all of this coolness. Subscribing only takes seconds.

Sign up for the Yireo newsletter


Legal information

Other Yireo sites

Get Social

About Yireo