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

COLORBALANCE2


Manually color balances an image in midtones, highlights, or shadows.

Download Script

last modified: June 19, 2015



USAGE: colorbalance2 [-c color] [-a amount] [-r region] [-l lowthresh] [-h highthresh] infile outfile
USAGE: colorbalance2 [-help]

-c ... color ........ color to modify: red (r), yellow (y), green (g),
..................... cyan (c), blue (b), magenta (m); default=red
-a ... amount ....... amount (percent) of color change; float>0; default=25
-r ... region ....... region to change: midtones (m), shadows (s),
..................... highlights (h); default=midtones
-l ... lowthresh .... low (shadow) value threshold; 0<=float<=100;
..................... default=25
-h ... highthresh ... high (hightlight) value threshold; 0<=float<=100;
..................... default=75

PURPOSE: To manually color balance an image in midtones, highlights, or shadows.

DESCRIPTION: COLORBALANCE2 manually color balances an image according to a user selected color, region and amount. The regions are midtones, shadows, or highlights.

ARGUMENTS:

-c color ... COLOR to modify. The choices are: red (r), yellow (y), green (g), cyan (c), blue (b) or magenta (m). The default=red

-a amount ... AMOUNT of color change. Values are float>=0 as percent, but one can go over 100%. The default=25.

-r region ... REGION of image to change. The choices are: midtones (m), shadows (s), or highlights (h). The default=midtones.

-l low ... LOW is shadow mask threshold value. Values are in the range 0<=float<=100. The default=25.

-h high ... HIGH is highlight mask threshold value. Values are in the range 0<=float<=100. The default=75.

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


Midtone Color Variation

Original Image

Arguments:
-c red -a 25

Arguments:
-c yellow -a 25

Arguments:
-c green -a 25

Arguments:
-c cyan -a 25

Arguments:
-c blue -a 25

Arguments:
-c magenta -a 25



Variation In Region For Color Red

Original Image

Arguments:
-r shadows

Arguments:
-r midtones

Arguments:
-r highlights



Variation In Region For Color Red

Original Image

Arguments:
-r shadows

Arguments:
-r midtones

Arguments:
-r highlights

Animation



What the script does is as follows:

  • Selects the appropriate channel
  • Reads the input
  • Creates a constant color image the same size as the input
  • Creates a solarized grayscale version of the input image
  • Composites the 3 images together to form the output

This is equivalent to the following IM commands for the case of midtones:

  • convert -quiet "$infile" $dir/tmpI.mpc
  • fact=`convert xc: -format "%[fx:$amount/100]" info:`
  • convert $dir/tmpI.mpc \
    \( +clone -fill $color -colorize 100% \) \
    \( -clone 0 -modulate 100,0,100 -solarize 50% -level 0x50% -evaluate multiply $fact \) \
    -compose overlay -composite "$outfile"