Nyxynyx Nyxynyx - 1 year ago 130
Linux Question

ImageMagick converting the same image multiple times?

I notice a slowdown in my server when using ImageMagick to resize some photos. Doing a

shows that there are several similar
commands (7) being executed at the same time on the same image. Is this normal for ImageMagick, or did my code somehow execute Imagemagick's
mulitple times on the same image?

I am using ImageMagick
ImageMagick 6.7.9-6 2012-09-18

enter image description here

convert --version

Version: ImageMagick 6.7.9-6 2012-09-18 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Additional Info

  • There are 16 cores on the CentOS 6.3 i686 system.

  • Typical input image file is about 10-100KB.

  • The number of duplicate (not just similar) commands range from 2-16.


The log shows that there are no duplicate calls to
to resize the same image twice.

Answer Source

To debug this, one needs more details.

  • "... several similar convert commands at the same time...": how many is 'several' exactly?!

  • How many CPU (cores) does this system have?

  • How 'similar' exactly, what are the differences within this similarity?!

  • What are the parent:child relationships between these similar commands?! (pstree command)

  • How big is your typical input image?!

Please also report the full output of convert -version.

This seems to be a web service, guessing from the input JPEG's directory that can be seen in the screenshot. *Are you sure that there are not several convert commands started by the web service for every upload? -- Are you sure that the web service isn't contacted multiple times by the web client for every image to be converted?*


If your convert -version reports as one feature OpenMP, then your ImageMagick is multi-threaded, enabling it to simultaneously run multiple threads to process one large image. This can increase efficiency very greatly when it comes to process large image files. (But it can slow down overall performance greatly too, if you process many small files...)

My guess is that you don't see multiple (16) concurrent processes in the htop output, but multiple (16) concurrent execution threads.

For the typical use case of processing small files, you should try it with automatic multi-threading disabled, by setting this environment variable:


You can also benchmark your ImageMagick command to get closer to the optimal number of threads to be used. Adding -bench iterations prints the elapsed time and efficiency for one or more threads of the specific command:

convert                                        \
  -bench 40                                    \
   /home/photos/public_html/2012/0926/some.jpg \
  -resize 300                                  \

Your ImageMagick 6.7.9 is able to apply progressive threading while benchmarking a command. (It doesn't make much sense to test with -bench in non-OpenMP installations...)

See also this discussion in the official ImageMagick forum.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download