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.

RIPPLES


Applies various circular ripple effects to an image.

Download Script

last modified: December 15, 2018



USAGE: ripples [-t type ] [-a amplitude] [-w width] [-o offset] [-r rmin] [-c center] [-p power ] [-s shadeval] infile outfile
USAGE: ripples [-h or -help]

-t .... type ............. type of circular ripple effect; displace (or d), modulate (or m)
.......................... blend (or b); default=displace
-a .... amplitude ........ amplitude or height of displace ripple; integer>=0; default=20
-w .... width ............ width of single ripple; integer>0; default=25
-o .... offset ........... offset or extra spacing between ripples; integer>=0; default=0
-r .... rmin ............. minimum distance from center to first ripple; integer>=0; default=25
-c .... center ........... center point for circular ripples; center=cx,cy; integer>=0
-p .... power ............ power or exponent controlling tapering of ripples; float>=0;
.......................... power=1 is linear taper; default=0 or no taper
-s .... shadeval ......... shading effect; shadeval=AzimuthxElevation angles;
.......................... integers; 0<=azimuth<=360; 0<=elevation<=90; default is no shading;

PURPOSE: To apply various circular ripple effects to an image.

DESCRIPTION: RIPPLES applies various circular ripple effects to an image. The effects are displacement which produces water-like ripples, modulation and blend. The latter are more suited for creating wavy patterns.

ARGUMENTS:

-t type ... TYPE of circular ripple/wave effect. Choices are: displace or (d), modulate (or m) and blend (or b). The displace option produces water-like ripples. The modulate and blend options are better at producing wavy patterns. The default is displace.

-a amplitude ... AMPLITUDE or height of ripple. Values are integers>=0. The default=20. Types of modulate and blend are not sensitive to this parameter.

-w width ... WIDTH is the width or wavelength of a single ripple. Values are integers>0. The default=25.

-r rmin ... RMIN is the spacing from the center to the first ripple. Values are integers>=0. The default=25.

-c center ... CENTER=cx,cy are the comma separated coordinates in the image from where the circular ripples eminate. Values are integers>=0. The default is the center of the image.

-p power ... POWER is the exponent that controls the tapering of the ripples/waves. Values are floats>=0. Power=0 is no taper. Power=1 is linear taper. The default=1

-s shadeval ... SHADEVAL=AZIMUTHxELEVATION are the optional x separated shading angles of azimulth (around) and elevation (up) for the lighting effect. Values are integers, 0<=azimuth<=360 degree and 0<=elevation<=90 degrees. See -shade for more details.

NOTE: Requires IM 6.4.2-8 or higher due to the use of -t distort polar/depolar.

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


Disperse

Original

Arguments:
-t d -a 20 -w 25 -o 0 -r 25 -p 0

Arguments:
-t d -a 20 -w 25 -o 0 -r 25 -p 1

Arguments:
-t d -a 20 -w 25 -o 12 -r 25 -p 0

Arguments:
-t d -a 20 -w 25 -o 25 -r 25 -p 0

Radial Ripple:
Profile

Radial Ripple:
Profile

Radial Ripple:
Profile

Radial Ripple:
Profile



Disperse

Original

Arguments:
-t d -a 30 -w 25 -o 0 -r 25 -p 1

Arguments:
-t d -a 40 -w 50 -o 0 -r 50 -p 2

Radial Ripple:
Profile

Radial Ripple:
Profile



Disperse

Original

Arguments:
-t d -a 20 -w 25 -o 50 -r 50 -p 0

Arguments:
-t d -a 20 -w 35 -o 0 -r 35 -p 1

Arguments:
-t d -a 20 -w 35 -o 35 -r 35 -p 1

Radial Ripple:
Profile

Radial Ripple:
Profile

Radial Ripple:
Profile



Disperse Animation

Arguments:
-t d -a 20 -w 25 -o 128 -p 0
-r varied in steps of 12.5 from 0 to 75



Modulate

Original

Arguments:
-t m -a 20 -w 35 -o 0 -r 35 -p 0

Radial Ripple:
Profile



Blend

Original
convert -size 200x200 -seed 10 plasma:fractal -colorspace gray \
-blur 0x5 -emboss 1 -shade 120x45 -contrast-stretch 0 -blur 0x5 \
clouds.jpg

Arguments:
-t b -a 20 -w 25 -o 0 -r 0 -p 1 -s 120x45

Radial Ripple:
Profile

Arguments:
+level-colors blue,white

-resize 100x50%



What the script does is as follows for displace effect:

  • Creates a linear gradient and applies a ripple to it
  • Converts image to polar coordinates
  • Displaces the polar image by the ripple pattern
  • Converts the diplaced image from polar coordinates back to rectangular coordinates

This is equivalent to the following IM commands for zero spacing, i.e. a wave pattern

  • ww=`convert $infile -format "%[fx:w]" info:`
  • hh=`convert $infile -format "%[fx:h]" info:`
  • hmr=`convert xc: -format "%[fx:$hh-$rmin]" info:`
  • convert \( -size 1x${hmr} gradient: -negate \) \
    -channel G \
    -fx "-pow(($hmr-j)/$hh,$power)*0.5*sin(2*pi*u*$hh/$width)+0.5" \
    -separate +channel \
    \( -size 1x${rmin} xc:"gray(50%)" \) \
    +swap -append \
    -scale ${ww}x${hh}! \
    $tmp1
  • convert $infile -t distort depolar -1,0,$cx,$cy $infile
  • composite $tmp1 $infile -t displace 0x${amplitude} $infile
  • convert $infile -t distort polar -1,0,$cx,$cy $outfile