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

SOFTLIGHT


Applies soft light to an image.

Download Script

last modified: September 26, 2017



USAGE: softlight [-a amount] [-s smooth] [-p percent] [-c color] infile outfile
USAGE: softlight [-h or -help]

-a ... amount ..... amount (intensity) of soft light; integer>=0;
................... default=80
-s ... smooth ..... smoothing extent of soft light; integer>=0; default=50
-p ... percent .... percent of white from thresholding; 0<=integer<=100;
................... default=5
-c ... color ...... color of softlight; any valid opaque IM color;
................... default=white

PURPOSE: To apply soft light to an image.

DESCRIPTION: SOFTLIGHT applies soft light to an image.

ARGUMENTS:

-a amount ... AMOUNT (intensity) of soft light. Values are integers greater or equal to 0. The default=80.

-s smooth ... SMOOTH is the smoothing extent of the soft light. Values are integers greater or equal to 0. The default=50.

-p percent ...PERCENT of white from thresholding used to create the soft light. Values are integers between 0 and 100. The default=5.

-c color ... COLOR of the soft light. Any valid opaque IM color is allowed. The default=white.

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 - Variation In Amount

Original
(image)

Arguments:
(default)
-a 80 -s 50 -p 5 -c white

Arguments:
(default)
-a 40 -s 50 -p 5 -c white

Arguments:
(default)
-a 100 -s 50 -p 5 -c white



Example 2 - Variation In Smoothness

Original

Arguments:
(default)
-a 80 -s 50 -p 5 -c white

Arguments:
(default)
-a 80 -s 10 -p 5 -c white

Arguments:
(default)
-a 80 -s 25 -p 5 -c white



Example 3 - Variation In Percent

Original

Arguments:
(default)
-a 80 -s 50 -p 5 -c white

Arguments:
(default)
-a 80 -s 50 -p 1 -c white

Arguments:
(default)
-a 80 -s 50 -p 20 -c white



Example 4 - Pink Light

Original

Arguments:
(default)
-a 55 -s 45 -p 5 -c pink



Example 5

Original
(image)

Arguments:
(default)
-a 80 -s 60 -p 5 -c white



Example 6

Original
(image)

Arguments:
(default)
-a 70 -s 60 -p 5 -c white

Arguments:
(default)
-a 45 -s 50 -p 5 -c pink

Arguments:
(default)
-a 45 -s 50 -p 5 -c goldenrod1



What the script does is as follows:

  • Creates a mask that represents some percent of the most whitish pixels in the image
  • Blurs the mask to soften it
  • Applies an attenuation factor to the mask to control the amount of softlight
  • Composes the image with pure white using the mask to create the output

This is equivalent to the following IM commands

  • amount=`convert xc: -format "%[fx:$amount/100]" info:`
  • convert $infile -set colorspace RGB \
    \( -clone 0 -fill $color -colorize 100% \) \
    \( -clone 0 $setcspace -colorspace HSB -channel G -negate -channel GB -separate +channel \
    -compose multiply -composite -contrast-stretch 0,${percent}% \
    -fill black +opaque white -blur 0x$smooth \
    -auto-level -evaluate multiply $amount \) \
    -compose over -composite $outfile