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

optimizing 'convert' speed

Post by shoansa »

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

Re: optimizing 'convert' speed

Post by shoansa »

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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: optimizing 'convert' speed

Post by snibgo »

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
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: optimizing 'convert' speed

Post by anthony »

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.
https://www.imagemagick.org/Usage/basics/#image_quality

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
https://imagemagick.org/Usage/
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: optimizing 'convert' speed

Post by glennrp »

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).
dattatembare
Posts: 5
Joined: 2018-06-27T13:11:39-07:00
Authentication code: 1152

Re: optimizing 'convert' speed

Post by dattatembare »

So the easiest improvement will be to use a different file format.
Which file format, can you please specify?
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.
Do you have some example for Java api?

Thanks!
Post Reply