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.

MOTTLE


Applies various mottle effects to an image.

Download Script

last modified: December 15, 2018



USAGE: mottle [-t type ] [-a amount] [-g granularity] [-c color] [-r region] [-n newseed] [-s] infile outfile
USAGE: mottle [-h or -help]

-t .... type ............. type of mottle effect; displace (or d), modulate (or m)
.......................... blend (or b); default=displace
-a .... amount ........... amount of displacement; integer>=0; default=5
-g .... granularity ...... granularity or size of mottled areas; float>=0; default=5
-c .... color ............ mixing color for blend effect; any valid IM color; default=black
-r .... region ........... blend region where color is applied; foreground (or f) or
.......................... background (or b); default=foreground
-n .... newseed .......... forced seed value; integer>0; default will randomly change seed
-s ....................... color shimmer for blend effect

PURPOSE: To apply various mottle effects to an image.

DESCRIPTION: MOTTLE various mottle effects to an image. The effect types are displacement, modulation and blend. The latter two are more suited for for application to binary images.

ARGUMENTS:

-t type ... TYPE of mottle effect. Choices are: displace or (d), modulate (or m) and blend (or b). The modulate and blend options are better suited for binary images. The default is displace.

-a amount ... AMOUNT of displacement in pixels. Values are integers>=0. The default=5. Modulate and blend are not sensitive to this parameter.

-g granularity ... GRANULARITY is the size of the mottled areas. Values are floats>=0. The default=5.

-c color ... COLOR is the mixing color for the type=blend effect. Any valid IM color is allowed. See http://imagemagick.org/script/color.php The default=white. When region=background, this produces a "cloud-like" color effect on a color image. When region=foreground, this produces a mottled color tinting effect to a color image.

-r region ... REGION is the location where the type=blend effect coloration is applied. Values are either foreground (f) or background (b). The default=foreground.

-n newseed ... NEWSEED is the forced seed value to use for randomization. This permits the pattern to be repeated. Values are integers>0. The default is to change the seed value randomly each time the script is run, thus causing somewhat different patterns each time the script is run.

-s ... Apply a color shimmer effect with type=modulate.

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: Disperse Variations

Original

Arguments:
-t d -a 5 -g 5

Arguments:
-t d -a 3 -g 3

Arguments:
-t d -a 2 -g 2

Arguments:
-t d -a 2 -g 1

Arguments:
-t d -a 3 -g 1

Arguments:
-t d -a 3 -g 0



Example 2: Disperse, Modulate and Blend Variations

Original

Arguments:
-t d -a 5 -g 5

Arguments:
-t d -a 3 -g 1

Arguments:
-t m -a 5 -g 5

Arguments:
-t b -a 5 -g 5 -c yellow -r f

Arguments:
-t b -a 5 -g 10 -c white -r b

Example 3: Disperse, Modulate and Blend Variations

Original

Arguments:
-t d -a 2 -g 2

Arguments:
-t d -a 2 -g 1

Arguments:
-t m -a 2 -g 0

Arguments:
-t m -a 1 -g 2

Arguments:
-t m -a 1 -g 1

Arguments:
-t m -a 1 -g 0

 

Arguments:
-t m -a 5 -g 3

Arguments:
-t m -a 5 -g 3 -s

 

   

 

Arguments:
-t b -a 5 -g 3 -c red -r f

Arguments:
-t b -a 5 -g 3 -c red -r b

 

   


What the script does is as follows:

  • Creates a random, blurred image
  • Applies the random, blurred image to the input image
    as a displacement map or as an image which is composited by multiplication or blending

This is equivalent to the following IM commands for type=displace

  • ww=`convert $infile -format "%[fx:w]" info:`
  • hh=`convert $infile -format "%[fx:h]" info:`
  • convert -size ${ww}x${hh} xc: +noise Random -virtual-pixel tile \
    -blur 0x${granularity} -contrast-stretch 0% -channel G -separate $tmp0
  • composite $tmp0 $infile -displace ${amount}x${amount} $outfile