There’s always a gotcha.

It turns out these features must be new because they’re not in the ubuntu binaries or source. So here comes a quick guide to compiling image magick under ubuntu.

First, install the source for the Ubuntu one:

apt-get source imagemagick

Change into the directory and steal the configure line from debian/rules.

Download and extract the source for the current imagemagick:

root@sierry-kinkaid:~# unxz ImageMagick-6.6.2-4.tar.xz
root@sierry-kinkaid:~# tar xf ImageMagick-6.6.2-4.tar

Now, if like me you go straight ahead and configure/make/make install you’ll have a bunch of problems. Namely:

1) You’ll have barfed over the rather excellent package management debian/ubuntu uses.
2) You won’t be able to remove it and it’ll get smacked down by updates from Ubuntu.
3) You won’t actually be able to do anything with it as it won’t be able to load even jpg and png images.

So in reverse order you’ll need to install dev headers for the things you care about. Something like this will cover the bases:

root@sierry-kinkaid:~# dpkg -l *jpeg*
ii libjpeg62 6b-15ubuntu1 The Independent JPEG Group’s JPEG runtime library
ii libjpeg62-dev 6b-15ubuntu1 Development files for the IJG JPEG library

Ensuring you have the headers for each format you desire. For JPEG2000 you might need to grab a delegate called Jasper and compile that. I’ve not tried.

So after configuring using the previously stolen line:

MagickDocumentPath=”/usr/share/doc/imagemagick” ./configure \
–prefix=/usr \
–mandir=\$${prefix}/share/man \
–infodir=\$${prefix}/share/info \
–with-gs-font-dir=/usr/share/fonts/type1/gsfonts \
–with-magick-plus-plus \
–with-djvu \
–enable-shared \
–without-dps \
–without-fpx \
–with-perl-options=’INSTALLDIRS=vendor’ \
–x-includes=/usr/include/X11 \
–x-libraries=/usr/lib/X11

Once it has configured check the Delegate Configuration section of the output to ensure you have support for the libraries you require. For example on mine now I have:

JPEG v1 –with-jpeg=yes yes

Which is good. If you have a flag saying yes and a no in the far right column that means your compile line requested it but the headers/library were not found. If you need it, go get them.

Now just hit make as usual. It’s worth me pointing out here that on my desktop Ubuntu install I had to install a lot of -dev headers yet here on my netbook for some reason I haven’t had to install any.

While that’s ticking away it’s a good time to think about what this is going to clash with when we install it. We’re going to use check install so we need to flag up what packages it’s going to provide when installed. On my box, using dpkg -l *magick*:

ii imagemagick 7:6.5.7.8-1ubuntu1 image manipulation programs
un imagemagick-doc (no description available)
un libmagick9-dev (no description available)
ii libmagickcore-dev 7:6.5.7.8-1ubuntu1 low-level image manipulation library – development files
ii libmagickcore2 7:6.5.7.8-1ubuntu1 low-level image manipulation library
ii libmagickcore2-extra 7:6.5.7.8-1ubuntu1 low-level image manipulation library – extra codecs
ii libmagickwand-dev 7:6.5.7.8-1ubuntu1 image manipulation library – development files
ii libmagickwand2 7:6.5.7.8-1ubuntu1 image manipulation library

We can’t uninstall imagemagick due to a few dependencies normally so on my desktop I removed everything else mentioned without problems. Here on my netbook I can’t remove libmagickwand2 or anything so let’s see how we go.
Install checkinstall. Once the make has finished run the command with no args in that directory. You’ll want to change option 2 to read:

imagemagick

and option 11 to be a comma separated list of packages it provides:

libmagickcore2, libmagickcore2-extra, libmagickcore-dev, libmagickwand2, libmagickwand-dev

So whilst I’m waiting for the make to finish, which could be donkeys on this little thing I’m going to remove the headers and extras to be on the safer side:

diziet@sierry-kinkaid:~/$ sudo aptitude remove libmagickcore-dev libmagickcore2-extra libmagickwand-dev

Do make sure this doesn’t remove libx11-dev or anything whilst your code is compiling. It will produce interesting compiler errors. If you do hit a snag with the compile it is almost definitely down to missing headers. Scroll up, see what it couldn’t find, and install that package.

Once it’s compiled run checkinstall. My output was this:

root@sierry-kinkaid:~/ImageMagick-6.6.2-4# checkinstall

checkinstall 1.6.1, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.

The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]: n

Please write a description for the package.
End your description with an empty line or EOF.
>> ImageMagick 6.6.2-4 Source Build
>>

*****************************************
**** Debian package creation selected ***
*****************************************

*** Warning: The package name “ImageMagick-6.6.2” contains upper case
*** Warning: letters. dpkg might not like that so I changed
*** Warning: them to lower case.

This package will be built according to these values:

This package will be built according to these values:

0 – Maintainer: [ Paul Downs ]
1 – Summary: [ ImageMagick 6.6.2-4 Source Build ]
2 – Name: [ imagemagick ]
3 – Version: [ 4 ]
4 – Release: [ 1 ]
5 – License: [ GPL ]
6 – Group: [ checkinstall ]
7 – Architecture: [ i386 ]
8 – Source location: [ ImageMagick-6.6.2-4 ]
9 – Alternate source location: [ ]
10 – Requires: [ ]
11 – Provides: [ libmagickcore2, libmagickcore2-extra, libmagickcore-dev, libmagickwand2, libmagickwand-dev ]

Enter a number to change any of them or press ENTER to continue:

Once it’s finished wrangling elect the defaults it now presents you with:

Some of the files created by the installation are inside the build
directory: /root/ImageMagick-6.6.2-4

You probably don’t want them to be included in the package,
especially if they are inside your home directory.
Do you want me to list them? [n]:
Should I exclude them from the package? (Saying yes is a good idea) [y]:

After installation you may find it necessary to run ldconfig so your build tools etc. pick up the new version.

As a note, another method of doing this would be to copy over the debian directory from the source download before and vi the debian/rules, debian/control etc. files as necessary then run the stand debian build commands or the more hackish debian/rules file itself. YMMV but I opted for the checkinstall route here as I’m unlikely to need the .deb anywhere else or require updates to it.

You will of course want to pin your installs at this point.

This entry was posted in Programming and tagged , , , , . Bookmark the permalink.