Page 1 of 1

Loop and increase the number in mpr:list

Posted: 2019-05-09T01:37:42-07:00
by Shizu
Hello, I'm using this code

Code: Select all

magick *.png -write mpr:list -delete 0--1 mpr:list[1] mpr:list[0] -alpha off +repage ( -clone 0 -clone 1 -compose difference -composite -threshold 0 ) ( -clone 0 -clone 2 -compose multiply -composite ) -delete 0,1 +swap -alpha off -compose copy_opacity -composite +repage %.png

to create a list to and extract the differences between lossless .png [0] & [1], [0] & [2], [0] & [3] ....The problem is, I don't know how to loop and change the number in mpr:list[1] to [2], [3],.... Is there any code or cmdl ine to do that? (Sry for my English)
Example:
#0Image
#1Image
#2Image
Output of #1 and #2:
ImageImage

Can anyone help me with this? Thank you very much
I'm using IM 7.0.8-44 x64 on Win10.

Re: Loop and increase the number in mpr:list

Posted: 2019-05-09T03:19:22-07:00
by snibgo
IM doesn't contain code to loop as you describe. That would need a shell script loop.

The task can be done without loops, using "-layers composite". Insert a "NULL:" image in the list after the first image. Then "-compose difference -layers composite" will replace the list with a list of difference images.

Re: Loop and increase the number in mpr:list

Posted: 2019-05-09T06:12:49-07:00
by Shizu
Sorry, I'm a total noob, I don't know how to write code, I just copy from other thread and modify some part...I used this code before, is there any error in it?

Code: Select all

magick *.png -write mpr:list -delete 1--1 null: mpr:list[1--1] -compose difference -layers composite output%.png
but the result was blank. I tried adding "-negate" the color seem weird and I can't fix or make the background become transparent...

Re: Loop and increase the number in mpr:list

Posted: 2019-05-09T06:38:46-07:00
by snibgo
Your command works fine for me, with IM v7.0.7-28. But you read all the *.png images, then write outputs also with a .png extension. So if you run the command twice, you will get bad results.