Email iconarrow-down-circleGroup 8arrow-rightGroup 4arrow-rightGroup 4Combined ShapeUntitled 2Untitled 2ozFill 166crosscupcake-iconPage 1HamburgerPage 1Page 1Oval 1Page 1Email iconphone iconpushpinblog icon copy 2 + Bitmap Copy 2Fill 1medal copy 3Group 7twitter iconPage 1

Recently we have been doing some work with an existing client to see
how fast we can make some image transformations (the one I am currently
targeting is the composite function).

In order to run these tests in a portable testing environment we created
some test environments on Virtual Machines (check out my guide to setting up
a bare bones Debian install
) where we can easily manipulate the resources
and software configuration for testing

Some targets we have tested so far have been the affect of:

  • CPU speed and # cores
  • RAM
  • Disk IO
  • Tweaking Imagemagick settings

Over at Etsy there is a very helpful blog post on image processing and optimising the
speed of these processes that gave us some good guidance.

Anyhow, I digress, we have been doing all our testing on Debian squeeze, with the
versions of Imagemagick and GraphicsMagick available in the Debian repositories.

These versions are quite outdated (as such there may be performace lurking in the
subsequent versions)

  • Imagemagick v6.6.0-4 (released in 2010-03-07)
  • GraphicsMagick v1.3.12 (March 8, 2010)

Building from source on debian

We wanted to test a custom build of Imagemagick in order to allow us to configure
the build with the Quantum Depth set to 8 (a little more info can be found here and on the Imagemagick forums) as there are a few accounts on StackOverflow and the forums to indicate that this can improve memory usage and image processing times.

We built Debian with no packages preinstalled during the installation process,
trying to follow some of the other guides did not account for this – my main source of frustration was not knowing which image libraries (and more importantly that I required the -dev packages too) I needed to get Imagemagick working

Steps

  • Install wget sudo apt-get install wget
  • Install the build tools sudo apt-get install build-essential
  • Install required image libraries, in this case libpng and libjpeg sudo apt-get install libpng12-0 libjpeg-progs
  • Important: Install dev versions of image libraries sudo apt-get install libjpeg-dev libpng-dev

We found out to some frustration that without the dev packages for the image libraries, you couldn’t build Imagemagick with support for them!

The next steps are pretty straightforward:

Download and unpack a version of Imagemagick

For example:

wget http://www.imagemagick.org/download/Imagemagick-6.7.9-2.tar.gz tar -xzf Imagemagick-6.7.9-2.tar.gz cd Imagemagick-6.7.9-2 

Configure and build Imagemagick

n.b the following steps are available at the Imagemagick website

Remove the quantum depth flag for a default install, you may or may not need
the --enable-shared=yes --with-modules=yes flags

./configure --with-quantum-depth=8 

Double check the output of this command for example if you need png and jpeg
compatibility then check the third column is set to yes. If it says ‘no’ then
you may not have installed the image libraries properly

PNG --with-png=yes yes JPEG v1 --with-jpeg=yes yes 

If you’re happy with that then run make and then sudo make install if make
does not return any errors. As soon as make install is complete then you can
run make check to run the test suite and verify your installation.

If you need to revisit your configuration you can run identify -list format
and identify -list configure. If those do not work, then you have botched the
installation!

If you need even more speed when processing jpeg images, you could look at libjpeg-turbo

[libjpeg-turbo is] libjpeg-turbo is a derivative of libjpeg that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal.

Share: