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

VIBRANCE


Applies a non-linear change to the saturation of an image.

Download Script

last modified: September 26, 2017



USAGE: vibrance [-a amount] infile outfile
USAGE: vibrance [-h or -help]

-a ... amount ... vibrance amount as percent; integer; default=0; no change

PURPOSE: To apply a non-linear change to the saturation of an image.

DESCRIPTION: VIBRANCE applies a non-linear change to the saturation of an image.

ARGUMENTS:

-a amount ... AMOUNT is the percent non-linear change in saturation. Values are -100<=integers<=100. The default=0 (no change).

REQUIREMENTS: IM 6.5.3-4 or greater in order to support -compose blend with convert.

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


Original Image

Arguments:
-a 100

Arguments:
-a -100



What the script does is as follows:

  • Copies the image and modulates its saturation
  • Copies the image, separates the saturation and
    lightness channels, blends them and applies a
    gamma adjustment computed from the amount to
    create a mask
  • Uses the mask to composite the original and
    modulated images

This is equivalent to the following IM commands

  • if [ $amount -lt 0 ]; then
    gval=`convert xc: -format "%[fx:1-$amount*(0.25/100)]" info:`
    else
    gval=`convert xc: -format "%[fx:1-$amount*(0.50/100)]" info:`
    fi
  • amount=`convert xc: -format "%[fx:100+$amount]" info:`
  • convert $infile \
    \( -clone 0 -modulate 100,$amount,100 \) \
    \( -clone 0 -colorspace HSL -channel GB -separate +channel -negate \
    -compose blend -define compose:args=$blend -composite -gamma $gval \) \
    -compose over -composite \ $outfile