Welcome to the private homepage of Johannes Jarolim, Salzburg, Austria, Europe. Willkommen auf der privaten Homepage von Johannes Jarolim, Salzburg, Österreich.

Recently, i had to update my virtual private server at hosteurope (one of the big hosting players in germany)  and got a machine with ubuntu release 10.04 and plesk 10.4.4 installed.

Problem

Imagemagick was very slow – converting even small images needed alot processing power and a lot of time. This wasn’t acceptable since this high load was rendering my server useless after uploading a new image or clearing the thumbnail cache on my YAPB-Installation. This wasn’t the imagemagick behaviour i was used to expierience:

# time convert -resize 100x100 source.jpg target.jpg

real    0m7.693s
user    0m7.615s
sys     0m0.024s

Analysis

After searching for the phenomen for quite a time i stumbled over this article – It seems that some library is buggy thus thwarting out all image conversion processes on my machine.

Solution

As proposed, i’d tried to recompile imagemagick with the option –disable-openmp. Sadly, this wasn’t exactly an easy job since the imagemagick resisted to work properly afterwards quitting resize-jobs with the error message “no code delegate for this image“. I’m not such a linux-talker after all: fine.

Since i needed some time to figure it out – here a little step-4-step tutorial to install all needed delegates and to compile imagemagick. The actual directories may have to be adapted since i installed this at 11-2011 downloading ImageMagick 6.7.3-7. Please note that you may also need to prefix most of the bash-commands with the command “sudo” if you’re not logged in as root (which is probably the more secure way to do things on a linux bash).

Update sources.list

First, i needed to update my sources.list so i could install the needed delegates via apt-get:

# vi /etc/apt/sources.list

There i inserted a new line for my distribution

deb-src http://de.archive.ubuntu.com/ubuntu lucid main restricted universe multiverse

If you’re searching for the entry needed for your own distribution, have a look on this page:
http://wiki.ubuntuusers.de/sources.list (german page)

Install all needed infrastructure

After that i startet an update and installed all needed components for an imagemagick-compilation this way:

# apt-get update
# apt-get install build-essential
# apt-get build-dep imagemagick

The third step also neatly installed all needed delegates for my everyday work like libjpeg and libpng for the according support.

Download and compile ImageMagick

After installing the needed infrastructure i went to my root user folder, downloaded Imagemagick, configured and compiled it.

# cd ~
# wget  ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
# tar xvfz ImageMagick.tar.gz
# cd  ImageMagick-6.7.3-7
# ./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' 'CFLAGS=-g -O2' 'LDFLAGS=-Wl,-Bsymbolic-functions' 'CPPFLAGS=' 'CXXFLAGS=-g -O2' '--disable-openmp'
# make install

I did get the options for ./configure from the lame version already being installed on my system:

# /usr/bin/convert -list configure

The only thing i did was to remove all X11-Options (my VPS is a headless system without GUI) and adding the initially recommended –disable-openmp option.

Replace the old version

After that, i had a newly compilated version of ImageMagick lying under ~/ImageMagick-6.7.3-7/utilities – Last step was to backup the existing version of convert and to copy the new version to /usr/local/bin:

# cd /usr/local/bin

There already was a convert – i renamed it:

# mv ./convert ./convert-old-6.5.7-8

Now i copied the new version into the location

# cp ~/ImageMagick-6.7.3-7/utilities/convert .

Enjoy the beauty of fast image resizing

Voila – Now, convert was running again in acceptable speed:

# time convert -resize 100x100 source.jpg target.jpg

real    0m0.039s
user    0m0.023s
sys     0m0.016s

Five Replies

  1. 7. January 2012, 22:14
    Comment by Alexander Kappler
    Hi,
    Thank you for your HowTo!
    I had exactly the same issue with my server @ hosteurope / VPS / Ubuntu.
    With the help of your HowTo I could also fix the problem.
  2. 11. February 2012, 13:34
    Comment by Quero
    Thank you very much! It works now :D <3
  3. 13. March 2012, 17:27
    Comment by daniloaz
    There is another solution based on MAGICK_THREAD_LIMIT environment variable. Check this out: High CPU load when converting images with ImageMagick
    • 1. July 2014, 21:48
      Comment by Johannes
      Unfortunately, i couldn't get the very elegant MAGICK_THREAD_LIMIT solution to run with TYPO3. So i had to do again some compiling on another hosteurope VPS of a customer.

      So: June 2014 and the solution is still valid ;-)
  4. 6. July 2012, 11:24
    Comment by Jonatan Littke
    The solution with MAGICK_THREAD_LIMIT worked perfectly for me, much easier than recompiling. Thanks.

You're welcome to leave a message here

Reload Image