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.

MIDGRADIENT


Creates a two-color gradient with adjustable mid-color location.

Download Script

last modified: May 15, 2020



USAGE: midgradient [-l length] [-t thickness] [-c1 color1] [-c2 color2] [-d direction] [-o offset] outfile
USAGE: midgradient [-help]

-l ... length ...... length in pixels along the gradient; integer>0;
.................... default=256
-t ... thickness ... thickness in pixels of the gradient; integer>0;
.................... default=50
-c1 ... color1 ..... color at start of gradient; any valid Imagemagick
.................... color; default=red
-c2 ... color2 ..... color at end of gradient; any valid Imagemagick
.................... color; default=blue
-d ... direction ... direction angle of the gradient relative to
.................... default direction 0 pointing up; integer choice of
.................... 0, 90, 180 or 270; default=0
-o ... offset ...... offset point in percent along gradient of mid-color
.................... (equal blend of color1 and color2); 0<=integer<=100;
.................... default=50 (middle of the gradient)

PURPOSE: To create a two-color gradient with adjustable mid-color location.

DESCRIPTION: MIDGRADIENT creates a two-color gradient with adjustable mid-color location. The gradient can vary, up/down or left/right according to a direction or rotation angle relative to 0 upwards from color1 to color2.

ARGUMENTS:

-l length ... LENGTH in pixels along the gradient. Values are integers>0. The default=256.

-t thickness ... THICKNESS in pixels of the gradient. Values are integers>0. The default=50.

-c1 color1 ... COLOR1 is the color at start of gradient. Any valid Imagemagick color is allowed. The default=red.

-c2 color2 ... COLOR2 is the color at end of gradient. Any valid Imagemagick color is allowed. The default=blue.

-d direction ... DIRECTION angle of the gradient relative to the default direction of 0 pointing upward. Choices are integer of 0, 90, 180 or 270. The default=0.

-o offset ... OFFSET point in percent along gradient of mid-color (equal blend of color1 and color2). Values are 0<=integers<=100. The default=50 (middle of the gradient).

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

Arguments:
-d 90 -o 25 -c1 red -c2 blue
Arguments:
-d 90 -o 50 -c1 red -c2 blue
Arguments:
-d 90 -o 75 -c1 red -c2 blue


What the script does is as follows:

  • Computes the average of the two colors
  • Creates a gradient between color1 and the average color
    for the desired fraction of the total length
  • Creates a gradient between the average color and color2
    for the remaining fraction of the total length
  • Appends the two gradients and rotates as desired