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.

WIGGLE


Creates a sinusoidal wiggling animation.

Download Script

last modified: December 16, 2018



USAGE: wiggle [-f frames] [-d delay] [-w wavelengths] [-D direction] [-a amount] infile outfile
USAGE: wiggle [-h or -help]

-f ... frames ........ number of frames to generate in the animation; integer>0;
...................... default=25
-d ... delay ......... animation delay between frames; integer>0; default=5
-w ... wavelengths ... number of sinusoidal wavelengths to span the image dimension;
...................... float>0; default=0.5; (typically in half or integer values)
-D ... direction ..... direction of the scrolling wiggles; choices are: left, right,
...................... up, down; default=right
-a ... amount ........ amount of wiggle distortion; integer>0; default=10

PURPOSE: Creates a sinusoidal wiggling animation.

DESCRIPTION: WIGGLE creates a sinusoidal wiggling animation. The wiggling can be either horizontal or vertical.

ARGUMENTS:

-f frames ... FRAMES are the number of frames to generate in the animation. Value are integers>0. The default=25.

-d delay ... DELAY is the animation delay between frames in ticks. Values are integers>0. The default=5.

-w wavelengths ... WAVELENGTHS are the number of sinusoidal wavelengths to span the image dimension. Values are floats>0. The default=0.5. (Typically values are in half or integer amounts).

-D direction ... DIRECTION of the scrolling wiggles; choices are: left (l), right (r), up (u), down (d). The default=right.

-a amount ... AMOUNT of wiggle distortion. Values are integers>0. The default=10.

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


Example 1 -- Variation in Wavelength

Original:
(source)

Arguments:
-w 0.5

Arguments:
-w 1

Arguments:
-w 2

Arguments:
-w 4

Arguments:
-w 8

Arguments:
-w 16



Example 2 -- Variation in Direction

Original:
(source)

Arguments:
-D right

Arguments:
-D left

Arguments:
-D up

Arguments:
-D down



Example 3 -- Variation in Amount

Original:
(source)

Arguments:
-w 0.5 -a 5

Arguments:
-w 0.5 -a 10

Arguments:
-w 0.5 -a 20

Arguments:
-w 0.5 -a 40



Example 4

Original:

convert -size 600 -font ubuntu \
label:"THIS IS A WIGGLE TEST" \
-bordercolor white -border 50x0 text.jpg

Arguments:
-w 0.5 -a 5 -D right

Arguments:
-w 0.5 -a 3 -D down



What the script does is as follows:

  • Processes the following in loop over the sinusoidal phase
  • Reads the input image
  • Creates a same size linear gradient
  • Compute the phase for a given frame
  • Create a sinusoidal distortion image for a given wavelength and phase
  • Distort the input image using the sinusoidal distortion image
  • Save the resulting frame to MIFF: format
  • Converts the MIFF: file to a GIF aniimation
  • Writes the animation to the output file

This is equivalent to the following IM commands for the case of direction=right

  • convert -quiet "$infile" +repage "$tmp1A"
  • ww=`convert -ping $tmp1A -format "%w" info:`
  • w1=$((ww-1))
  • incr=`convert xc: -format "%[fx:360/$frames)]" info:`
  • convert "$tmp1A" -sparse-color barycentric "0,0 black $w1,0 white" $tmp2A`
  • ( for ((k=0; k phase=`convert xc: -format "%[fx:-$k*$incr]" info:`
    convert $tmp1A \( $tmp2A -function Sinusoid "$wavelengths,$phase,0.5,0.5" \) \
    -define compose:args=$amount,0 -compose displace -composite miff:-
    done
    ) | convert -delay 20 - -loop 0 "$outfile"