Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial (non-profit) 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

    Please read the Pointers For Use on my home page to properly install and customize my scripts.

TRANSITIONS


Applies an animated transition between two images.

Download Script

last modified: December 16, 2018



USAGE: transitions [-m mode] [-f frames] [-d delay] [-p pause] [-r] [-e] infile1 infile2 maskfile [outfile]
USAGE: transitions [-h or -help]

-m .... mode ......... mode of transition; wipe or dissolve; default=wipe
-f .... frames ....... number of frames in animation; frames>1; default=20
-d .... delay ........ delay between frames; delay>0; default=10
-p .... pause ........ pause delay for two undistorted input images;
...................... pause>0; default=50
-r ................... reverse the animation sequence and append it to the end
-e ................... exponentiate maskfile to make the animation
...................... start more gradually. Mostly useful for mode=dissolve

The two input files and mask file 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 apply an animated transition between two images.

DESCRIPTION: TRANSITIONS applies an animated transition between two images using a mask image to control the transition. The first image will show where the mask is black and the second image will show where the mask is white. The mask will be made gradually more an more white as each frame is composited. NOTE that this is not a true warping morph. It is simply an animated masked composite.

ARGUMENTS:

-m mode ... MODE of transition. Values are wipe or dissolve. The default is wipe. Note that dissolve is generally only useful for very gradual graylevel changes in the mask image, such as a linear or radial gradient.

-f frames ... FRAMES is the total number of frames in the animation (including infile1 and infile2 as the start and end frames. Values are integers > 1. The default is 20.

-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

-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.

-e ... If supplied, then the maskfile will be exponentiated to make the animation start more gradually. This is useful for most dissolve mode transitions.

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


Hillary "Rodman" Clinton
(No Political Statement Intended - Just A Play On Names)

 

Hillary Rodham Clinton

Dennis Rodman

 

Maskfile - Gradient
convert -size 128x128 gradient: maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Radial Gradient
convert -size 128x128 xc: -fx \
"xx=i-w/2; yy=j-h/2; \
rr=hypot(xx,yy); rr/hypot(w/2,h/2)" \
maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Shutters
convert -size 128x16 gradient: miff:- |\
convert -size 128x128 tile:miff: maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Random Noise
convert -size 128x128 xc: +noise Random \
-virtual-pixel tile -fx intensity \
-contrast-stretch 0% maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Blurred Random Noise
convert -size 128x128 xc: +noise Random \
-virtual-pixel tile -fx intensity \
-blur 0x6 -contrast-stretch 0% \
maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - More Blurred Random Noise
convert -size 128x128 xc: +noise Random \
-virtual-pixel tile -fx intensity \
-blur 0x18 -contrast-stretch 0% \
maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Plasma
convert -size 128x128 plasma:fractal \
-virtual-pixel tile -fx intensity maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e



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

 

Flower 1

Flower 2

 

Maskfile - Gradient
convert -size 240x160 gradient: maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Radial Gradient
convert -size 240x160 xc: -fx \
"xx=i-w/2; yy=j-h/2; \
rr=hypot(xx,yy); rr/hypot(w/2,h/2)" \
maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Shutters
convert -size 128x16 gradient: miff:- |\
convert -size 240x160 tile:miff: maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Alternating Gradient
convert \( -size 16x240 gradient: -rotate 90 \) \
\( -clone 0 -rotate 180 \) -append miff:- |\
convert -size 240x160 tile:miff: -flop maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10

Maskfile - Random Noise
convert -size 240x160 xc: +noise Random \
-virtual-pixel tile -fx intensity \
-contrast-stretch 0% maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Blurred Random Noise
convert -size 240x160 xc: +noise Random \
-virtual-pixel tile -fx intensity \
-blur 0x6 -contrast-stretch 0% \
maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - More Blurred Random Noise
convert -size 240x160 xc: +noise Random \
-virtual-pixel tile -fx intensity \
-blur 0x18 -contrast-stretch 0% \
maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e

Maskfile - Plasma
convert -size 240x160 plasma:fractal \
-virtual-pixel tile -fx intensity maskfile.jpg

Arguments:
-m wipe -f 21 -d 10 -p 10

Arguments:
-m dissolve -f 21 -d 10 -p 10 -e



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

  • i=1
  • frames=`expr $frames - 1`
  • while [ $i -le $frames ]; do
  • aa=`convert xc: -format "%[fx:100*$i/$frames]" info:`
  • convert $infile1 $infile2 \( $maskfile -evaluate add $aa% \) -composite miff:- |\
    convert -delay $delay $tmp0 -page +0+0 - -page +0+0 $tmp0
  • i=`expr $i + 1`
  • done
  • convert $tmp0 -loop 0 $outfile