How to add support for the JPEG image format

Solution 1:

I fixed the problem by installing from source the jpeg encoding library available at http://www.ijg.org/files/jpegsrc.v8c.tar.gz.

cd /usr/local/src
tar xvfz jpeg-8c.tar.gz
cd jpeg-8c
./configure --enable-shared --prefix=$CONFIGURE_PREFIX
make
sudo make install

Then I re-installed ImageMagick from source:

cd /usr/local/src
tar xvfz ImageMagick-6.6.9-5.tar.gz
cd ImageMagick-6.6.9-5
export CPPFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp
make
sudo make install

Now its working, I've tested it like this:

sam@ubuntu:~/RubymineProjects/project/tmp$ identify 1.jpg
1.jpg JPEG 128x106 128x106+0+0 8-bit sRGB 2.22KB 0.000u 0:00.000

Solution 2:

If you decide to build ImageMagick from source, you need to be prepared to manually resolve all dependencies. Unless you have a pressing need, you should install all software on Ubuntu from a repository -- either the official repos or a PPA.

If you install Imagemagick using APT (apt-get, Synaptic, Software Center, etc.), then JPG files will work just fine, as I confirmed on my machine.

If your reason for building from source is to get a more recent version, hunt for a PPA that tracks the most recent version. If you're building from source in order to help with development, then you should find out from the Imagemagick folks just what is required to succesfully build it from source. It might be that you need to specify some flag to ./configure or have some development library installed before running ./configure.

But normally, building from source just needlessly complicates things.

Oh, by the way, Red Hat and Ubuntu use different names for packages. So if yum complains about a missing package, it shouldn't be surprising if apt-get can't find a package by that name. You shouldn't mix package managers on a system unless you have a really good reason to do so. Even then, try every other option first.

Solution 3:

Note that the no decode delegate error can (quite confusingly) result from imagemagick (or some part of it) not finding the file. So before running to reinstall imagemagick, check with identify -list format and convert -list configure whether the JPEG format is supported, and if it is, the problem will probably be somewhere else.

For example, convert -resize 50% foo\ bar.jpg gave me a no decode delegate for this image format eror, but convert -resize 50% 'foo bar.jpg' worked perfectly.

Solution 4:

If you have just installed php5-imagick, try also installing the full imagemagick package. This will install all required libraries, such as the jpeg one.

sudo apt-get install imagemagick

Then restart your webserver to reload al libraries:

sudo service apache2 restart

JPEG decoding should now work without error.