Page 1 of 1

merging multiple commands and avoiding output to disk

Posted: 2013-08-11T15:29:06-07:00
by logicom
Dear ImageMagic community,

I just started using ImageMagic and this remarkable software allowed me to get the desired result.

However I would ask you to help me with the right approach and especially syntax for two things:

1. Goal is to avoid disk I/O but rather to perform all calculations in memory.
2. how to condense multiple commands in one command line instruction, or as least as possible, to avoid multiple calls to convert / compose

process goes like this:
Step1. Take screenshot1 to memory
//-- some random commands-time in between--// imagex flow have to be interrupted here? (mpr: might not work ?) maybe miff?
Step2. Take a bit changed bitmap-screenshoot2 in memory
Step3. Process
Step4. Return Result to the clipboard

code snippet:

1. >convert clipboard: \\path\A.bmp [here I would prefer to write in memory and refer to it latter ...?]
<some random widows command line instructions>
2. >convert clipboard: clipboard:\\B.bmp
3. >composite \\path\A.bmp clipboard:\\B.bmp -compose ModulusSubtract clipboard:\\C.bmp
4. >convert clipboard:\\C.bmp -fill black -draw "rectangle xa1,ya1,xa2,ya2" -draw "rectangle xb1,yb1,xb2,yb2" clipboard:\\D.bmp
5. >convert ephemeral:\\path\A.bmp clipboard:\\D.bmp -compose Difference -composite mpc:\\path\E.bmp
6. >convert mpc:\\path\E.bmp clipboard:

and this works.

However drawback is that I have in step:
1. writing to HD
3. reading from HD
5. reading and deleting from HD
6. eventually I have residuals and I would have to add additional step to delete those
since putting straight convert ephemeral:mpc:\\path\E.bmp clipboard: doesn't work.

Although I try to use clipboard on a convenient way, it was not enough to solve my problem.

My question is how to get rid of aforementioned drawbacks while minimizing number of calls to convert.exe and composite.exe by merging commands in this particular example.

If possible at all, this would have to be adapted for MS cmd command line.
I am using latest standalone windows version of ImageMagic.

Kind Regards.

Re: merging multiple commands and avoiding output to disk

Posted: 2013-08-11T16:18:33-07:00
by snibgo
Steps 2 to 6 (Windows script) is something like:

Code: Select all

convert ^
  clipboard: ^
  A.bmp ^
  -compose ModulusSubtract -composite ^
  -fill black -draw "rectangle xa1,ya1,xa2,ya2" -draw "rectangle xb1,yb1,xb2,yb2" ^
  E.bmp
If we want to use A.bmp again, the simplest way is to save it to a memory register:

Code: Select all

convert ^
  clipboard: ^
  A.bmp -write mpr:saveA ^
  -compose ModulusSubtract -composite ^
  -fill black -draw "rectangle xa1,ya1,xa2,ya2" -draw "rectangle xb1,yb1,xb2,yb2" ^
  mpr:saveA ^
  +swap ^
  -compose Difference -composite ^
  clipboard: