Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

FXTRANSITIONS


Creates an animated transition between two images using a special effect distortion.

Download Script

last modified: August 12, 2015



USAGE: fxtransitions [-e effect] [-f frames] [-d delay] [-p pause] [-b bgcolor] [-r] infile1 infile2 [outfile]
USAGE: fxtransitions [-h or -help]

-e .... effect ....... transition effect type: blur, explode, implode, pixelize,
...................... recursion, spin, spread, swirl, zoomin, zoomout;
...................... default=blur
-f .... frames ....... number of frames in animation; frames>1; default=10
-d .... delay ........ delay between frames; delay>0; default=20
-p .... pause ........ pause delay for two undistorted input images;
...................... pause>0; default=50
-b .... bgcolor ...... background color for use only with effect=zoomout
-r ................... reverse the animation sequence and append it to the end

The two input files must be the same size.

The output file must be of type that supports multi-frames, such as gif.

If no output file is specified, the animation will be displayed automatically
but not saved to a file

PURPOSE: To create an animated transition between two images using a special effect distortion.

DESCRIPTION: FXTRANSITIONS creates an animated transition between two images using a special effect distortion. The special effects distortions include: blur, explode, implode, pixelize, recursion, spin, spread, swirl, zoomin and zoomout.

ARGUMENTS:

-e effect ... EFFECT is the type of distortion to use as the means for creating the animated transition between the two input images. The choices are: blur, explode, implode, pixelize, recursion, spin, spread, swirl, zoomin and zoomout. The default=blur.

-f frames ... FRAMES is the number of frames in the animation of each of the two input images. Values are integers > 1. The default is 10. Thus the total number of frames will be 2*frames. If the animation is reversed, then the total number of frames will be 4*frames-2.

-d delay ... DELAY between frames. Values are integers>0. The default=20

-p pause ... PAUSE is the delay to use for the first and last frame of the animation, i.e. the delay for each of the input images. The default=50

-b bgcolor ... BGCOLOR is the background color to use for fill when the effect is zoomout. Any valid IM color specification. The default=black.

-r ... If supplied, then reverse the animation sequence, remove the first and last frames of the reversed sequence and append these reversed frames to the end of the animation.

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.


EXAMPLES


Two Flowers
http://www.jhlabs.com/ip/filters/

Flower 1

Flower 2

Blur

Arguments:
-e blur -f 18 -d 20 -p 50 -r

 

Explode

Arguments:
-e explode -f 18 -d 20 -p 50 -r

 

Implode

Arguments:
-e implode -f 18 -d 20 -p 50 -r

 

Pixelize

Arguments:
-e pixelize -f 18 -d 20 -p 50 -r

 

Recursion

Arguments:
-e recursion -f 18 -d 20 -p 50 -r

 

Spin

Arguments:
-e spin -f 18 -d 20 -p 50 -r

 

Spread

Arguments:
-e spread -f 18 -d 20 -p 50 -r

 

Swirl

Arguments:
-e swirl -f 18 -d 20 -p 50 -r

 

Zoom In

Arguments:
-e zoomin -f 18 -d 20 -p 50 -r

 

Zoom Out

Arguments:
-e zoomout -f 18 -d 20 -p 50 -r -b black

 


What the script does is as follows:

  • Composites the two images together using a mask image
  • The mask images is gradually made lighter

This is equivalent to the following IM commands for the case of swirl with reversed frames.

  • w1=`convert $tmpA -format "%w" info:`
  • h1=`convert $tmpA -format "%h" info:`
  • count=`expr $frames - 1`
  • factor=`convert xc: -format "%[fx:360/$count]" info:`
  • # animate first image
  • i=0
  • convert $tmpA $tmp0
  • while [ $i -lt $count ]; do
  • k=`expr $i + 1`
  • ff=`convert xc: -format "%[fx:3*360*(1000^($k*$factor/360)-1)/999]" info:`
  • convert $tmpA -swirl "$ff" miff:- |\
    convert -delay $delay $tmp0 -page +0+0 - -page +0+0 $tmp0
  • i=`expr $i + 1`
  • done
  • # animate second image
  • k=$count
  • while [ $k -gt 0 ]; do
  • ff=`convert xc: -format "%[fx:3*360*(1000^($k*$factor/360)-1)/999]" info:`
  • convert $tmpC -swirl "$ff" miff:- |\
    convert -delay $delay $tmp0 -page +0+0 - -page +0+0 $tmp0
  • k=`expr $k - 1`
  • done
  • convert $tmpC miff:- |\
    convert -delay $delay $tmp0 -page +0+0 - -page +0+0 $tmp0
  • # set delay for first and last frame
  • convert $tmp0 -coalesce \
    \( -clone 0 -set delay $pause \) -swap 0,-1 +delete \
    \( +clone -set delay $pause \) -swap -1,-2 +delete \
    -quiet -layers Optimize $tmp0
  • # reverse sequence, remove first and last frames, append to animation
  • convert $tmp0 -coalesce \( -clone -2-1 \) \
    -quiet -layers Optimize $tmp0
  • convert $tmp0 -loop 0 $outfile