Command example to create animated wave...
Posted: 2016-08-24T18:50:11-07:00
This isn't a question or problem, for a change. I just thought I'd share this fairly simple effect I worked out with IM7. It turns any image into an animated GIF with a ripple effect like a flag waving. Here's an example of the output...
The command here is in Windows command line syntax...
The command takes any image as input, resizes it to the next smaller width divisible by 10, and creates a stack of ten copies. Then it uses "-distort affine" to shift each image in the stack to the left by 5% more than the last. The "-distort" operation relies on "-virtual-pixel tile" to make it act like "-roll".
After all the images in the stack are shifted incrementally, a "-wave" effect is added, then they're all un-shifted back to their original locations. The result is each image in the stack has a wave a little further along than the last. Finish up by setting a delay and output the stack to a GIF named by using the filename of the input image.
Here's another example...
The movement is pretty smooth for only using a stack of ten images, and the output file sizes are relatively small for the amount of visible movement in the animation. More detail in the input image will mean a larger file of course, but a simple image like the flag at the top is under 100k.
To use this in a Windows BAT script would require changing all the single percent signs "%" to doubles "%%". To use it in a *nix shell it requires escaping all the parentheses with backslashes "\", changing all the double quotes to single quotes, and changing all the continued line carets "^" into backslashes "\".
The command here is in Windows command line syntax...
Code: Select all
magick input.jpg ^
-background none ^
-set filename:f "%[t]" ^
-resize %[fx:w-(w%10)]x ^
-dither floydsteinberg ^
-duplicate 9 ^
-virtual-pixel tile ^
-distort affine "0,0 -%[fx:t*(w*0.05)],0" ^
-wave %[fx:min(w,h)*0.01]x%[fx:w*0.5] ^
-distort affine "0,0 %[fx:t*(w*0.05)],0" ^
-set dispose background ^
-set delay 15 ^
-loop 0 ^
"%[filename:f]_wavy.gif"
After all the images in the stack are shifted incrementally, a "-wave" effect is added, then they're all un-shifted back to their original locations. The result is each image in the stack has a wave a little further along than the last. Finish up by setting a delay and output the stack to a GIF named by using the filename of the input image.
Here's another example...
The movement is pretty smooth for only using a stack of ten images, and the output file sizes are relatively small for the amount of visible movement in the animation. More detail in the input image will mean a larger file of course, but a simple image like the flag at the top is under 100k.
To use this in a Windows BAT script would require changing all the single percent signs "%" to doubles "%%". To use it in a *nix shell it requires escaping all the parentheses with backslashes "\", changing all the double quotes to single quotes, and changing all the continued line carets "^" into backslashes "\".