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

SINESCROLLIMAGE


Creates a sinusoidal curved scrolling image animation.

Download Script

last modified: July 31, 2018



USAGE: sinescrollimage [-w width ] [-b bgcolor ] [-a amplitude ] [-r repeats] [-p phase] [-f frames] [-d delay] [-D direction] [-m mode ] [-R range] infile [bgfile] outfile

USAGE: sinescrollimage [-h or -help]

-w ... width ....... width of animation in pixels; integer>0; default=500; height will
.................... be determined from the image height and the amplitude
-b ... bgcolor ..... background color for the animation frames; any valid IM color
.................... is allowed; default=white
-a ... amplitude ... amplitude of the sine wave as a multiplier of the image
.................... height; float>=0; default=1
-r ... repeats ..... number of repeats of the sine waveform to span the image width;
.................... float>0; default=1; (typically in half or integer values)
-p ... phase ....... phase of the sinusoidal wave; choices are 0 and 90; default=0
-f ... frames ...... number of frames to generate in the animation; integer>0;
.................... default=25
-d ... delay ....... animation delay between frames; integer>0; default=30
-D ... direction ... direction of the scrolling; choices are: left or right;
.................... default=left
-m ... mode ........ mode for the type of sine wave; choices are: constant (amplitude)
.................... and tapered (to zero amplitude); default=constant
-R ... range ....... range of the sine taper as percent of width of the image;
.................... 1<=integer<=100; default=100 (tapered over the full width);
.................... nominal value is 75

bgfile is optional and will be tiled (or cropped) to replace the background color

PURPOSE: Creates a sinusoidal curved scrolling image banner animation.

DESCRIPTION: SINESCROLLTEXT creates sinusoidal curved scrolling image banner animation. The scrolling can be either to the right or left. The amplitude of the sine wave can be either constant or tapered to zero.

ARGUMENTS:

-w width ... WIDTH of animation in pixels. Values are integers>0. The default=500. The animation height will be determined from the image height and the amplitude.

-b bgcolor ... BGCOLOR is the background color for the animation frames. Any valid IM color is allowed. The default=white.

-a amplitude ... AMPLITUDE (height up or down) of the text sine wave as a multiplier of the text height. Values are floats>=0. The default=1.

-r repeats ... REPEATS are the number of repeats of the sine waveform cycle to span the image width. Values are floats>0. The default=1. (typically, in half or integer values).

-p phase ... PHASE of the sinusoidal wave. The choices are 0 and 180. The default=0.

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

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

-D direction ... DIRECTION of the scrolling. Choices are: left (l) or right (r). The default=left.

-m mode ... MODE for the type of sine wave amplitude. The choices are: constant (c) and tapered (t) to zero amplitude. The default=constant.

-R range ... RANGE of the sine taper to zero amplitude as percent of width of the image. Values are 1<=integer<=100. The default=100 (tapered over the full width). A nominal value is 75.

bgfile is optional and will be tiled (or cropped) to replace the background color.

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

Original:

Arguments:
-w 400 -b skyblue -a 1 -r 0.5 -m constant

Arguments:
-w 400 -b skyblue -a 1 -r 0.5 -m constant -p 180

Arguments:
-w 400 -b skyblue -a 1 -r 1 -m constant

Arguments:
-w 400 --b skyblue -a 1 -r 1 -m constant -D right

Arguments:
-w 400 -b skyblue -a 1 -r 2 -m constant

Arguments:
-w 400 -b skyblue -a 2 -r 1 -m constant

Arguments:
-w 400 -b skyblue -a 1 -r 1 -m tapered -R 100

Arguments:
-w 400 -b skyblue -a 1 -r 1 -m tapered -R 75

Arguments:
-w 400 -b skyblue -a 1 -r 1 -m tapered -R 50



Example 2

Original:

Background Image:

Arguments:
-w 400 -b skyblue -a 1 -r 1 -m constant



What the script does is as follows:

  • Reads the input and extends it by the desired width
  • Creates a sinusoidal displacement map
  • Processes the following in loop over the extended image's roll
  • Rolls the image by an amount determined by the number of frames
  • Applies the displacement map
  • Collects the results for each iteration in a miff: file
  • 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 mode=constant and bgcolor=skyblue

  • convert -quiet "$infile" +repage $tmp1A
  • WxH=`convert -ping $tmp1A -format "%wx%h" info:`
  • ww=`echo $WxH | cut -dx -f1`
  • hh=`echo $WxH | cut -dx -f2`
  • ww1=$((width-1))
  • ww2=$((width+ww))
  • displace=`convert xc: -format "%[fx:$hh*$amplitude/2]" info:`
  • ht=`convert xc: -format "%[fx:ceil($hh+$amplitude*$hh)]" info:`
  • convert $tmp1A -gravity east -background "$bgcolor" -extent ${ww2}x${ht}! $tmp1A
  • convert $tmp1A -extent ${width}x${ht}! \
    -sparse-color barycentric "0,0 black $ww1,0 white" \
    -function Sinusoid "$repeats,$phase" \
    -gravity west -background white -extent ${ww2}x${ht}! $tmp2A
  • (
    for ((k=0; k<frames; k++)); do
    roll=`convert xc: -format "%[fx:$k*round($ww2/$frames)]" info:`
    convert \( $tmp1A -roll -${roll}+0 \) $tmp2A -background "$bgcolor" -virtual-pixel background \
    -define compose:args=0,$displace -compose displace -composite -compose over \
    -gravity west -crop ${width}x${ht}+0+0 +repage $tileproc miff:-
    done
    ) | convert -delay $delay - -loop 0 "$outfile"