new users first attempt on a bit more complex script

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?".
Locked
nospam
Posts: 1
Joined: 2020-03-03T00:53:04-07:00
Authentication code: 1152

new users first attempt on a bit more complex script

Post by nospam »

Hi, I'm dabbling around with imageMagick for a while now, but only for file conversions

But now I've concocted a script to visualize the differences between two black and white bitmaps.
It seems to work at last, but it takes its time and is the result of much trial and error.

So I would like to get some hints on posibilities for optimization.

The scipts take two input file, and first determines the similarities, additions & deletions and color codes them.
It then creates one output file from all three and one each from the identical parts plus the deletions or additions.
At last it creates an animated gif from the last two images.

Code: Select all

magick "file1.png" -write mpr:old +delete ^
       "file2.png" -write mpr:new +delete ^
       ^
       ^( mpr:old mpr:new -compose Multiply  -composite +level-colors ,"#404040" -write mpr:idn ^) ^
       ^( mpr:old mpr:new -compose Minus_Src -composite +level-colors ,"#ff6060" -write mpr:del ^) ^
       -compose Plus -composite ^
       ^( mpr:old mpr:new -compose Minus_Dst -composite +level-colors ,"#6060FF" -write mpr:add ^) ^
       -compose Plus -composite ^
       -trim +repage ^
       -compose src-over ^
       -fill "#d0d0d0" -opaque "#000000" ^
       -bordercolor "#d0d0d0" -border 25x25 ^
       ^
       -write "diff.png" +delete ^
       ^
       ^( mpr:idn mpr:add -compose plus -composite ^
          ^( -clone 0 ^
             -trim +repage ^
             -compose src-over ^
             -fill "#d0d0d0" -opaque "#000000" ^
             -bordercolor "#d0d0d0" -border 25x25 ^
       ^
             -write "add.png" +delete ^
          ^) ^
       ^) ^
       ^
       ^( mpr:idn mpr:del -compose plus -composite ^
          ^( -clone 0 ^
             -trim +repage ^
             -compose src-over ^
             -fill "#d0d0d0" -opaque "#000000" ^
             -bordercolor "#d0d0d0" -border 25x25 ^
       ^
             -write "del.png" +delete ^
          ^) ^
       ^) ^
       ^
       -coalesce ^
       ^( -clone 0--1 -transparent "#000000" -flatten -trim ^) ^
       -crop %%[fx:u[-1].w]x%%[fx:u[-1].h]+%%[fx:u[-1].page.x]+%%[fx:u[-1].page.y] +repage ^
       -delete -1 ^
       ^
       -compose src-over ^
       -fill "#d0d0d0" -opaque "#000000" ^
       -bordercolor "#d0d0d0" -border 25x25 ^
       ^
       -layers optimize -loop 0 -set delay 50 ^
       "blink.gif"

Locked