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.

SINESCROLLTEXT


Creates a sinusoidal curved scrolling text animation.

Download Script

last modified: December 15, 2018



USAGE: sinescrolltext -t "text" [-w width ] [-f font] [-c color] [-b bgcolor ] [-a amplitude ] [-r repeats] [-p phase] [-F frames] [-d delay] [-D direction] [-m mode ] [-R range] [infile] outfile
USAGE: sinescrolltext [-h or -help]

-t ... text ........ text string to be used to create the animation; required argument
-w ... width ....... width of text in pixels; integer>0; default=500; height will
.................... be determined from the text height and the amplitude
-f ... font ........ font to use for the text; font name or path to font file;
.................... default=arial
-c ... color ....... color of text; any valid IM color is allowed; default=black
-b ... bgcolor ..... background color for the animation frames; any valid IM color
.................... is allowed; default=white
-a ... amplitude ... amplitude of the text sine wave as a multiplier of the text
.................... 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

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

PURPOSE: Creates a sinusoidal curved scrolling text banner animation.

DESCRIPTION: SINESCROLLTEXT creates sinusoidal curved scrolling text 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:

-t text ... TEXT string to be used to create the animation. This is a required argument

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

-f font ... FONT to use for the text. Either the font name or path to font file may be used. The default=arial.

-c color ... COLOR of the text. Any valid IM color is allowed. The default=black.

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

infile 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

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 1 -r 0.5 -m constant

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 1 -r 0.5 -m constant -p 180

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 1 -r 1 -m constant

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 2 -r 1 -m constant

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 2 -r 2 -m constant

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 2 -r 2 -m tapered -R 100

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 2 -r 2 -m tapered -R 50



Example 2

Input:

Arguments:
-t "THIS IS A TEST OF SINESCROLL" -w 400 -f ubuntu -b skyblue -a 1 -r 1 -m constant



What the script does is as follows:

  • Creates the text image and extents it to the height as desired by the amplitude
  • Creates a sinusoidal displacement map
  • Processes the following in loop over the the created text image 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

  • wd=$width
  • convert -size ${wd}x -background "$bgcolor" -fill "$color" -gravity center -font $font label:"$text" $tmp1A
  • hh=`convert -ping $tmp1A -format "%h" info:`
  • displace=`convert xc: -format "%[fx:$hh*$amplitude/2]" info:`
  • ht=`convert xc: -format "%[fx:ceil($hh+$amplitude*$hh)]" info:`
  • ww2=$((2*wd))
  • ww1=$((wd-1))
  • convert $tmp1A -extent ${wd}x${ht}! \
    -sparse-color barycentric "0,0 black $ww1,0 white" \
    -function Sinusoid "$repeats,$phase" \
    -gravity west -background white -extent ${ww2}x${ht}! $tmp2A
  • convert $tmp1A -gravity east -background "$bgcolor" -extent ${ww2}x${ht}! $tmp1A
  • (
    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 ${wd}x${ht}+0+0 +repage $tileproc miff:-
    done
    ) | convert -delay $delay - -loop 0 "$outfile"