I've been using ImageMagick for masking, recoloring via -clut, and resizing anywhere from several hundred to a several thousand images at a time. Ideally we would like to speed things up a bit if at all possible. I was curious if anyone had any tips on what I can do to optimize ImageMagick or its environment for these kinds of commands. Also what kind of hardware would ImageMagick would best utilize for these types of commands (CPU, GPU)?
I currently run ImageMagick on an
x86_64 Linux server with Ubuntu 14.04.1 LTS installed
CPU: Intel(R) Xeon(R) CPU X32
RAM: 8GiB System Memory DDR2 Synchronous 800 MHz
HD: 15k Sas drives
GPU: none
Any Imagemagick hardware and customization tips?
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Any Imagemagick hardware and customization tips?
General considerations. Note I am not an expert on optimizing.
See viewtopic.php?f=4&t=26801. You do not say what version of Imagemagick you are using? Perhaps upgrade to the latest version and enable OpenMP. Get as much RAM as possible/practical. Get faster processors.
I do not think OpenCL (to run an GPU) will help for just masking, recoloring/clut and resizing.
You do not provide any clue to what your command line or script is like. So make sure your command line is optimized. That is combine multiple command lines into one command line. Use clones or mpr format and parenthesis processing if you have multiple commands and want to combine them into one command line. Don't save intermediate files to disk. Use these methods to avoid multiple command lines.
Put commands in the proper IM 6 syntax order.
Remove meta data if not needed using -strip or +profile.
See viewtopic.php?f=4&t=26801. You do not say what version of Imagemagick you are using? Perhaps upgrade to the latest version and enable OpenMP. Get as much RAM as possible/practical. Get faster processors.
I do not think OpenCL (to run an GPU) will help for just masking, recoloring/clut and resizing.
You do not provide any clue to what your command line or script is like. So make sure your command line is optimized. That is combine multiple command lines into one command line. Use clones or mpr format and parenthesis processing if you have multiple commands and want to combine them into one command line. Don't save intermediate files to disk. Use these methods to avoid multiple command lines.
Put commands in the proper IM 6 syntax order.
Remove meta data if not needed using -strip or +profile.
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Any Imagemagick hardware and customization tips?
Thanks for the thorough response. One of the commands I regularly use involves taking a grey-scale image and recoloring it using separate gradient files via convert with the gradients using the -clut argument. The gradients are rarely changed. Is there anyway to keep the gradients in memory so it doesn't have to load them from the disk every time I want to convert an image into multiple colors?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Any Imagemagick hardware and customization tips?
To my knowledge, no. In memory format, mpr:, only stays in memory until the command finishes. However, you can create your gradient and save as MPC: format (memory mapped). Reading that over and over is supposed to be very fast. Writing it the first time is a bit slower than other formats. See
http://www.imagemagick.org/Usage/files/#mpc
http://www.imagemagick.org/Usage/files/#mpr
http://www.imagemagick.org/Usage/files/#mpc
http://www.imagemagick.org/Usage/files/#mpr
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Any Imagemagick hardware and customization tips?
I recolor an image with multiple gradients like so:
'convert img.png gradient_1.png -clut result_1.png'
'convert img.png gradient_2.png -clut result_2.png'
....
'convert img.png gradient_n.png -clut result_n.png'
Is there a way I can batch the process so the image to be converted stays in memory through the n recolors?
'convert img.png gradient_1.png -clut result_1.png'
'convert img.png gradient_2.png -clut result_2.png'
....
'convert img.png gradient_n.png -clut result_n.png'
Is there a way I can batch the process so the image to be converted stays in memory through the n recolors?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Any Imagemagick hardware and customization tips?
Windows BAT syntax. Adjust for other shells.
EDIT: corrected to use different gradients.
Code: Select all
convert ^
img.png ^
( +clone gradient_1.png -clut +write result_1.png +delete ) ^
( +clone gradient_2.png -clut +write result_2.png +delete ) ^
...
( +clone gradient_n.png -clut +write result_n.png +delete ) ^
NULL:
snibgo's IM pages: im.snibgo.com
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Any Imagemagick hardware and customization tips?
I'm somewhat of a novice when it comes to shells. What would I need to change to get this working on linux?snibgo wrote:Windows BAT syntax. Adjust for other shells.EDIT: corrected to use different gradients.Code: Select all
convert ^ img.png ^ ( +clone gradient_1.png -clut +write result_1.png +delete ) ^ ( +clone gradient_2.png -clut +write result_2.png +delete ) ^ ... ( +clone gradient_n.png -clut +write result_n.png +delete ) ^ NULL:
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Any Imagemagick hardware and customization tips?
For bash, change every ^ to \, and escape every parenthesis.
Code: Select all
convert \
img.png \
\( +clone gradient_1.png -clut +write result_1.png +delete \) \
\( +clone gradient_2.png -clut +write result_2.png +delete \) \
...
\( +clone gradient_n.png -clut +write result_n.png +delete \) \
NULL:
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Any Imagemagick hardware and customization tips?
If you convert your gradients once to mpc format and save them (with the corresponding .cache file) and do not upgrade IM, then using gradient_1.mpc ... gradient_N.mpc in your command should save time reading the gradients if you have to run this command for many input images. If you have to upgrade IM, then you may have to regenerate the gradient_X.mpc files.