optimizing 'convert' speed

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
Posts: 5
Joined: 2017-07-18T00:12:17-07:00
Authentication code: 1151

optimizing 'convert' speed

Post by shoansa » 2017-09-27T05:17:19-07:00

In my application I am using convert for modulating two images and producing resultant image.
The command is as follows:

Code: Select all

convert ( image1.png -modulate 100,100,100 ) ( image2.png -modulate 184,0,100 ) -composite result.png
Functionally it is working fine. But, for any 1000 x 1000 resolution image it takes around 700ms! Which is much bigger from my application stand point.

How can I optimize above command to get response faster?

Following are my system details:
Windows: Windows 10 Pro
Version: ImageMagick 7.0.7-1 Q16 x64 2017-09-09
Features: Cipher DPC Modules OpenMP
Resource limits:
Width: 214.748MP
Height: 214.748MP
Area: 8.39149GP
Memory: 3.90759GiB
Map: 7.81519GiB
Disk: unlimited
File: 1536
Thread: 4
Throttle: 0
Time: unlimited

I am very new to IM :D Thanks in Advance.
Last edited by shoansa on 2017-09-27T05:29:57-07:00, edited 2 times in total.

Posts: 5
Joined: 2017-07-18T00:12:17-07:00
Authentication code: 1151

Re: optimizing 'convert' speed

Post by shoansa » 2017-09-27T05:23:11-07:00

I have updated command to use depth 8 but still not improvement in time.

Code: Select all

convert ( image1.png -modulate 100,100,100 -depth 8 ) ( image2.png -modulate 184,0,100 -depth 8 ) -composite -depth 8 result.png

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

Re: optimizing 'convert' speed

Post by snibgo » 2017-09-27T05:41:07-07:00

Please don't multi-post. I have deleted your other post.

Your question doesn't relate to the OP, so I have split it to a new thread.

Your "-modulate 100,100,100" will have no effect, so can be removed.

Almost all the time will be in reading and writing PNG files. So the easiest improvement will be to use a different file format.
snibgo's IM pages: im.snibgo.com

User avatar
Posts: 8858
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: optimizing 'convert' speed

Post by anthony » 2017-09-27T18:11:13-07:00

Also using -depth 8 will have no effect on run time. It is only used to specify the output save depth, and that defaults to the images input depth (probably already 8 bit.

To get a speed improvement (with a loss in quality though not for this type of command) you want to change the compile time "Quality" setting.

See IM Examples, Basics, Controlling the Quality of Images for more details.

However like snibgo has mentioned most of the time will be involved in the I/O of the image files. There are ways to make this faster, the best being to keep the images in memory until all your processing is complete, That is if you do have more processing of the images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages

User avatar
Posts: 1162
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: optimizing 'convert' speed

Post by glennrp » 2017-09-30T08:46:39-07:00

When the output is PNG, the "quality" does not affect image appearance; it only affects the amount of compression. For your task, try "-quality 50" or "-quality 40", then adjust until you are happy with the compression speed and filesize (put this option at the end, just before "result.png" on your commandline).

Post Reply