Does ImageMagick convert the same image multiple times?

I noticed a slowdown on my server when using ImageMagick to resize some photos. Running htop shows that several similar convert (7) commands are executed simultaneously on the same image. Is this normal for ImageMagick, or is my code somehow executing Imagemagick convert 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 Information

  • The CentOS 6.3 i686 system has 16 cores.
  • A typical input image file is about 10-100 KB.
  • The number of repeated (not only similar) teams varies from 2 to 16.

Logging

The log shows that there are no duplicate calls to convert to resize a single image twice.

+4
source share
1 answer

To debug this, you need to get more details.

  • "... several similar conversion commands at the same time ...": how many "several" exactly?

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

  • How "similar" exactly, what are the differences in this similarity ?!

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

  • How big is your typical input image ?!

Also report the full output of convert -version .

It seems to be a web service guessing from the JPEG input directory, which can be seen in the screenshot. * Are you sure that there are no several conversion commands launched by the web service for each download? - Are you sure that the web service does not contact the web client several times for each image that needs to be converted? *


Update:

If your convert -version reports as one of the OpenMP functions, then your ImageMagick is multi-threaded, allowing it to run multiple threads at once to process one large image. This can increase efficiency very much when it comes to processing large image files. (But this can significantly slow down overall performance if you process many small files ...)

I assume that you are not seeing several (16) parallel processes in the output of htop , but several (16) parallel threads of execution.

For a typical case of processing small files, you should try disabling automatic multithreading by setting this environment variable:

 MAGICK_THREAD_LIMIT=1 

You can also compare your ImageMagick team to get closer to the optimal number of streams used. Adding -bench iterations prints the elapsed time and efficiency for one or more threads of a particular command:

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

Your ImageMagick 6.7.9 is capable of applying progressive stream processing by comparing a command. (It makes no sense to test with -bench on installations without OpenMP ...)

See also this discussion in the official ImageMagick forum .

+1
source

Source: https://habr.com/ru/post/1436421/


All Articles