Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial 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

COLORGLOW


Applies a color glow effect to an image.

Download Script

last modified: April 30, 2015



USAGE: colorglow -c coords [-a strength] [-s extent] [-f fuzzval] [-l lightness] [h hue] infile outfile
USAGE: colorglow [-help]

-c ... coords ...... coordinates for locating glow region; comma separate
.................... pair of integers within the image
-s ... strength .... strength (intensity) of glow; float>=0; default=100
-e ... extent ...... extent of glow; float>=0; default=5
-f ... fuzzval ..... fuzzval for locating glow region; 0<=float<=100;
.................... default=20
-l ... lightness ... percent change in lightness of glow color;
.................... float>=0; default=0
-h ... hue ......... percent change in hue of glow color;
.................... -100<=float<=100; default=0

NAME: COLORGLOW

DESCRIPTION: COLORGLOW applies color glow effect to an image. The user must supply a set of x,y coordinates within the image to located a contiguous region of color with some fuzz value tolerance. The color will be extracted from those coordinates automatically.

ARGUMENTS:

-c coords ... COORDS is the set of x,y coordinates to locate a contiguous region of color where the glow will be applied.

-s strength ... strength (intensity) of glow effect. Values are floats greater or equal to 0. The default=100.

-e extent ... extent is the extenting extent of the glow. Values are floats greater or equal to 0. The default=5.

-f fuzzval ... FUZZVAL for extracting the contiguous region of color. Values are floats between 0 and 100. The default=20.

-l lightness ... LIGHTNESS is the percent change in lightness of the glow color. Values are floats greater or equal to 0. The default=0.

-h hue ... HUE is the percent change in hue of the glow color. Values are floats between -100 and 100. The default=0.

NOTE: Results may vary with versions of IM prior to 6.7.7.8 due to color space changes. One can get close by varying the arguments, typically raising the strength to 150 and increasing extent by 1 or 2.

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
(image)

Arguments:
-c "133,78" -s 100 -e 5 -f 20



Example 2

Original
(image)

Arguments:
-c "250,268" -s 100 -e 8 -f 20

Arguments:
-c "133,78" -s 100 -e 8 -f 20 -h -20



Example 3

Original
(image)

Arguments:
-c "400,187" -s 100 -e 10 -f 30 -l 100



What the script does is as follows:

  • Locates the color at the selected coordinates
  • Creates an image of that color
  • Does a floodfill at those coordinates to make a binary mask
  • Composes the image with the color image using the mask to create the output

This is equivalent to the following IM commands

  • convert -quiet -regard-warnings "$infile" +repage "$tmpA1"
  • color=`convert $tmpA1 -format "%[pixel:u.p{$coords}]" info:`
  • lightness=`convert xc: -format "%[fx:$lightness+100]" info:`
  • hue=`convert xc: -format "%[fx:$hue+100]" info:`
  • strength=`convert xc: -format "%[fx:$strength/100]" info:`
  • convert $tmpA1 \
    \( -clone 0 -fill $color -colorize 100% -modulate $lightness,100,$hue \) \
    \( -clone 0 -blur 0x1 -fuzz $fuzzval% -fill none -draw "matte $coords floodfill" \
    -channel rgba -fill black +opaque none -fill white -opaque none -blur 0x$extent \
    -auto-level -evaluate multiply $strength \) \
    -compose over -composite $outfile