Speed up ImageMagick with libjpeg-turbo

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
aschaeffer
Posts: 4
Joined: 2013-08-30T07:06:58-07:00
Authentication code: 6789

Speed up ImageMagick with libjpeg-turbo

Post by aschaeffer »

Hi,

I did some development in a local environment. I put it online two days ago and was a bit disapointed by the time I need to resize image. So I was looking for all the tips I could find to resize my images faster.

First things I did, was to configure IM in 8-bits mode instead of 16-bits. Then I read about the libjpeg-turbo which is supposed to be 2x4 times faster to decode/encode JPG files. My only problem is that I don't know how to install it.

Here's what I did so far:

Install libjpeg-turbo :

Code: Select all

# wget 'http://sourceforge.net/projects/libjpeg-turbo/files/1.3.0/libjpeg-turbo-official_1.3.0_amd64.deb/download' -O libjpeg-turbo_1.3.0_amd64.deb
# dpkg -i libjpeg-turbo_1.3.0_amd64.deb
Selecting previously deselected package libjpeg-turbo.
(Reading database ... 25967 files and directories currently installed.)
Unpacking libjpeg-turbo (from libjpeg-turbo_1.0.1_i386.deb) ...
Setting up libjpeg-turbo (1.0.1-20100909) ...
Install ImageMagick using these commands :

Code: Select all

./configure --with-modules --with-perl --disable-static  --with-quantum-depth=8
make
sudo make install
There were no errors when during the installation, everything went fine.

I didn't notice any change. How could I confirm that libjpeg-turbo is correctly install and set up?

Thank you in advance for any help.
Arnaud
aschaeffer
Posts: 4
Joined: 2013-08-30T07:06:58-07:00
Authentication code: 6789

Re: Speed up ImageMagick with libjpeg-turbo

Post by aschaeffer »

Hi there,

still wondering where my problem is. On the other hand, I try to follow other tips:

Using a VPS server, i try to limit the number of thread used by Imagemagick. I'm supposed to have only 2 cores availables and by default, the imagemagick configuration is set up to 32. I try to limit the number of thread to 1, then 2, without any valuable changes.
http://superuser.com/questions/343648/l ... ng-limited

And i read this
http://www.imagemagick.org/Usage/api/#speed

But still, resizing this image (http://www.gratuit-en-ligne.com/telecha ... hatons.jpg) to 100x100pixels, take around 0.9 and 2 seconds.

My server isn't doing anything else besides this (the website is under development, so i'm the only one using it). Here's the VPS config :
1250 MB of RAM
2x 1.25 Ghz

Are this performance normal or is there something wrong with my server/imagemagick installation?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Speed up ImageMagick with libjpeg-turbo

Post by snibgo »

It may be worth checking that "convert -version" shows OpenMP.

On my Windows laptop, 2 cores, with IM v6.8.6-0 Q16, the command ...

Code: Select all

convert image-wallpaper-animaux-chatons.jpg -resize 100x100 j.jpg
... takes typically 0.25s elapsed.

When I limit the threads to 1 ...

Code: Select all

convert -limit threads 1 image-wallpaper-animaux-chatons.jpg -resize 100x100 j.jpg
... it takes typically 0.08s elapsed.

(The slow time with 2 threads is a known problem under Windows, and apparently will be fixed. See viewtopic.php?f=1&t=23986 )
snibgo's IM pages: im.snibgo.com
aschaeffer
Posts: 4
Joined: 2013-08-30T07:06:58-07:00
Authentication code: 6789

Re: Speed up ImageMagick with libjpeg-turbo

Post by aschaeffer »

Thank you for your answer.

Here's my version of IM:
#convert -version
Version: ImageMagick 6.8.6-9 2013-09-01 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: jpeg
My result in local was similar, way, way faster than on the server. Before incriminate the quality of the host, I would like to check if i do everything right.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Speed up ImageMagick with libjpeg-turbo

Post by snibgo »

You say, "My server isn't doing anything else besides this".

I would check how true that really is. Also check how much CPU time your process is taking. (I've forgotten the Unix tools for this.)
snibgo's IM pages: im.snibgo.com
aschaeffer
Posts: 4
Joined: 2013-08-30T07:06:58-07:00
Authentication code: 6789

Re: Speed up ImageMagick with libjpeg-turbo

Post by aschaeffer »

Sure, I'll give you more information about that.

I'm not an expert in linux, so I tried a top command :

Code: Select all

top - 11:58:10 up 10 days,  5:52,  2 users,  load average: 0.03, 0.02, 0.00
Tasks:  39 total,   1 running,  38 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1310720k total,   665072k used,   645648k free,        0k buffers
Swap:   327680k total,        0k used,   327680k free,   534480k cached
Other information coming from webmin :
Processor information AMD Opteron(TM) Processor 6274 , 2 cores
CPU load averages 0.00 (1 min) 0.00 (5 mins) 0.00 (15 mins)
CPU usage 1% user, 0% kernel, 0% IO, 99% idle
Real memory 128.52 MB used, 1.25 GB total
Virtual memory 0 bytes used, 320 MB total
Local disk space 1.61 GB used, 63 GB total
I'm having trouble to find how to give you the CPU usage of the convert process. I will continue to look for a way to do it and post it here when a got it!

Is there more information that would be relevant?

Thank you for helping me! :)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Speed up ImageMagick with libjpeg-turbo

Post by snibgo »

Is there more information that would be relevant?
I don't know. I'm not an expert at Unix, servers or IM configuration. I'm just asking the obvious question: Are the CPUs fully utilised?

Maybe it's also worth using "-bench" in your statement, but I don't know anything about it.
snibgo's IM pages: im.snibgo.com
Post Reply