Page 1 of 1

optimizing 'convert' speed

Posted: 2017-09-27T05:17:19-07:00
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.

Re: optimizing 'convert' speed

Posted: 2017-09-27T05:23:11-07:00
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

Re: optimizing 'convert' speed

Posted: 2017-09-27T05:41:07-07:00
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.

Re: optimizing 'convert' speed

Posted: 2017-09-27T18:11:13-07:00
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.

Re: optimizing 'convert' speed

Posted: 2017-09-30T08:46:39-07:00
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).

Re: optimizing 'convert' speed

Posted: 2018-08-15T13:05:29-07:00
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!