For example generate a range of images, then distort each image differently depending on the index...
Code: Select all
convert rose: -duplicate 29 -virtual-pixel tile \
-distort SRT '0,0 1, 0, %[fx:w*t/n],%[fx:h*t/n]' \
-set delay 10 -loop 0 rose_diagonal_roll.gif
![Image](http://www.imagemagick.org/Usage/anim_mods/rose_diagonal_roll.gif)
Here I use the image indexes to 'rotate' each image differently, and use -set with the image index to set a different 'pause delay' on the first image in the animation.
Code: Select all
convert rose: -duplicate 29 -virtual-pixel Gray \
-distort SRT '%[fx:360*t/n]' \
-set delay '%[fx:t==0?240:10]' -loop 0 rose_rotate.gif
![Image](http://www.imagemagick.org/Usage/anim_mods/rose_rotate.gif)
Without the use of image index calculations, the above would have required a external shell loop, to generate each frame individually, and a separate step to collect the frames to form the final animation. All of which slows down the whole process, instead of doing all in-memory.
The above examples are from IM Examples, Animated Distorts
Also this latest release also allows you to reference OTHER IMAGES via the %[fx:...] escape!
That is in an escape sequence 'u' now really does mean the first image, while 's' means the current image that is being looked at by the escape sequence.
Previously only one image was accessible, the 's' image, and as such its index 't' was uselessly set to zero. Also 'u==s' while 'v' did not exist.
With this release all the FX image indexing work as defined. So now.... 't=%p', 'n=%n' 'u' is always the first image, 'v' the second image, and the current image 's=u[t]'
I have no examples of using this ability to reference other images as yet, but possibilities include using a separate lookup table image or 'image map' to control the distortion in each frame of the animation. I look forward to see just what people use this for.
NOTE that as each image is 'distorted' in sequence, from first to last, the control map itself will also be distorted, and as such should be set to the last image so it does not change until all the other images have been distorted.