Loop and increase the number in mpr:list

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Shizu
Posts: 4
Joined: 2017-09-28T03:26:16-07:00
Authentication code: 1151

Loop and increase the number in mpr:list

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Loop and increase the number in mpr:list

Post 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.
snibgo's IM pages: im.snibgo.com
Shizu
Posts: 4
Joined: 2017-09-28T03:26:16-07:00
Authentication code: 1151

Re: Loop and increase the number in mpr:list

Post 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...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Loop and increase the number in mpr:list

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply