Page 1 of 1

Run imagemagick commands from a file in windows

Posted: 2018-06-04T22:09:31-07:00
by jb2233

I currently create a batch file (.bat) that executes over 400 commands, ie magick is executed over 400 times.

Is it possible, and if so how, can I build a file that contains the commands and then have magick (in one execution) run the 400 commands.

This would be for performance reasons. I have "MAGICK_THREAD_LIMIT=1" set to stop multiple threads from running, there are dependencies in the commands.

Many thanks for your consideration any help will be greatly appreciated.


Re: Run imagemagick commands from a file in windows

Posted: 2018-06-05T05:06:41-07:00
by snibgo
Yes, multiple invocations of magick can be combined into a single call to magick, which will take less time. In addition, if any invocations write results to disk that are only for reading by other invocations, these can be stored in memory within the single invocation, which reduces disk IO.

How? Just create one long magick command eg in a shell script, or put it in an IM script file that is called with "-script".

A couple of points:

1. A magick command has an implied "-write" before the final filename. As this will no longer be the final filename, you must make this explicit.

2. After each "-write filename", empty the image list, eg with "-delete 0--1".

3. If individual invocations change settings (eg "-compose CopyOpacity") but other invocations assume default values, you must explicitly set the values back to default (eg "-compose Over"). Sadly, there is no operation that changes all settings to defaults.

4. When combining multiple invocations into one, you should test that the outputs from the new code matches the output from the old code.

Re: Run imagemagick commands from a file in windows

Posted: 2018-06-05T16:28:54-07:00
by jb2233
Many thanks for the quick response, I will try this out