Performance getting hit in ImageMagick7 convert command

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
nabarun
Posts: 6
Joined: 2016-04-26T18:19:23-07:00
Authentication code: 1151

Performance getting hit in ImageMagick7 convert command

Post by nabarun » 2016-08-14T22:38:57-07:00

Hi all,
I analyzed 1000+ png images by converting them to jpg. During conversion I executed the convert command with time.

Code: Select all

command = "time ImageMagick-7.0.2-7/bin/convert "+ path.join(INPUT_DIR, jpg)+ "[0] -scene 1 -background white -flatten -colorspace sRGB -thumbnail 720x480 -resize 720x480! "+imagemagick_path+".jpg"

command = "time ImageMagick-6.8.5-7c/bin/convert "+ path.join(INPUT_DIR, jpg)+ "[0] -scene 1 -background white -flatten -colorspace sRGB -thumbnail 720x480 -resize 720x480! "+imagemagick_path+".jpg"
http://drive.google.com/file/d/0B8NpxtK ... sp=sharing

Can anyone confirm if this is known issue?

User avatar
fmw42
Posts: 22683
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance getting hit in ImageMagick7 convert command

Post by fmw42 » 2016-08-14T22:56:03-07:00

Why do you do resizing twice, once with -thumbnail and then again with -resize. Seems to me that you can do it just once.

PNG images are always sRGB, so using -colorspace sRGB is redundant.

specifying -scene 1 only affect the output number assigned if you had more than one frame or layer. Since you have use layer [0], there is no need for -scene 1

Imagemagick 7 by default installs as HDRI, which will be slower than without HDRI. Be sure you have compile your IM 7 and IM 6 with the same features and whether you have OpenMP or not the same and the same number of threads in use. Check your

Code: Select all

convert -version 
for IM 6 and for IM 7

snibgo
Posts: 9756
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Performance getting hit in ImageMagick7 convert command

Post by snibgo » 2016-08-14T22:58:25-07:00

It looks as though you are reading JPG, not PNG.

Are the Q-numbers the same? HDRI? Are the libraries the same? Did you run both tests twice, taking just the final readings? On tests like this, my computer is always much faster after the first run. I suppose the files are cached somewhere.

I would expect v7 to be slightly slower than v6 at most operations on colour images, because of the way pixel channels are accessed.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 22683
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance getting hit in ImageMagick7 convert command

Post by fmw42 » 2016-08-14T23:01:57-07:00

I notice the input JPG also, but forgot to mention that. JPG has not layers and does not support transparency. Though it can support CMYK. So the colorspace would be needed, but there is no need for -background ... -flatten, nor the double resizing, nor the [0], nor the -scene 1.

When you run tests, you probably should start with the simplest command and work up with more settings and methods incrementally to see where it is slowing down. Perhaps just a simple convert from PNG to JPG would suffice to see the timings.

But I suspect that much has to do with different IM compile features. Though snibgo may be correct with regard to the way IM 7 handles channels different from IM 6.

snibgo
Posts: 9756
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Performance getting hit in ImageMagick7 convert command

Post by snibgo » 2016-08-14T23:28:35-07:00

I agree with your comments, Fred. I haven't done timing tests on v6 versus v7. If I did, I would use the current versions of both, ensuring the libraries, Q-number, HDRI, OpenMP etc were identical.

I would expect v7 operations to be slightly slower than v6 for colour images, but much faster for grayscale. But I haven't tested this.
snibgo's IM pages: im.snibgo.com

nabarun
Posts: 6
Joined: 2016-04-26T18:19:23-07:00
Authentication code: 1151

Re: Performance getting hit in ImageMagick7 convert command

Post by nabarun » 2016-08-15T00:56:17-07:00

Thanks all, this has been indeed helpful. I was experimenting with ImageMagick convert pdf to jpg thumbnails. For this reason I had the first page only selected as scene 1. My requirement is to have 3 thumbnail sizes, 720x480 is one of them so added the resize option.

I verified the versions In my analysis I was doing a comparison of ImageMagick-6.8.5-7c and ImageMagick-7.0.2-7.The comparisonwas done against jpg to jpg and png to jpg. Accidentally I pasted the jpg-jpg call. Sorry for that. Here is the comparison snapshot for both the runs

https://drive.google.com/file/d/0B8Npxt ... sp=sharing

Here is the detail of the analysis where I got individual sys, user and real time stats then did a cumulative of them. https://drive.google.com/file/d/0B8Npxt ... sp=sharing

The help which I was expecting and got from you all was that there is a valid reason for slower performance. Thanks for clarifying that.

User avatar
fmw42
Posts: 22683
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance getting hit in ImageMagick7 convert command

Post by fmw42 » 2016-08-15T09:57:49-07:00

Please post your

Code: Select all

convert -version
for both systems. We would like to see that you are comparing apples to apples. You might also try compiling IM 7 without HDRI so you have both systems the same.

It would be a better test if you just did timings on

Code: Select all

convert input output
without all the other commands. That would verify the basic systems are slower and not any of the actual functions you call.

When I do timing tests, I run a loop of at least 10 and get the average value (excluding the first one, since it can be slower).

Post Reply