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.

SPLITTONE1


Applies a color splittone effect to an image

Download Script

last modified: December 15, 2018



USAGE: splittone1 [-sc shadowcolor] [-sa shadowamt] [-hc highlightcolor] [-ha highlightamt] [-b bri] [-c con] [-s sat] [-h hue] [-m method] [-p processing] infile outfile
USAGE: splittone1 [-help]

-sc ... shadowcolor ...... shadow color; any opaque IM color allowed;
.......................... default=black
-hc ... highlightcolor ... highlight color; any opaque IM color allowed;
.......................... default=white
-sa ... shadowamt ........ shadow amount; 0<integer<100; default=30
-ha ... highlightamt ..... highlight amount; 0<integer<100; default=30
-b .... bri .............. brightness; -100<integer<100; default=0
-c .... con .............. contrast; -100<integer<100; default=0
-s .... sat .............. saturation; -100<integer<100; default=0
-h .... hue .............. hue; -100<integer<100; default=0
-m .... method ........... order of shadow and highlight processing;
.......................... choices are: SH (shadow first) or HS (highlight
.......................... first; default=SH
-p .... processing ....... brightness and contrast processing; choices are:
.......................... pre (preprocessing), post (postprocessing, or
.......................... both; default=both

PURPOSE: To apply a color splittone effect to an image.

DESCRIPTION: SPLITTONE1 applies a color splittone effect to an image by adjusting shadow and highlight color separately.

ARGUMENTS:

-sc shadowcolor ... SHADOWCOLOR is the shadow color. Any opaque IM color is allowed. The default=black

-hc highlightcolor ... HIGHLIGHTCOLOR is the highlight color. Any opaque IM color is allowed. The default=black

-sa shadowamt ... SHADOWAMT is the shadow amount. Values are integers between 0 and 100. The default=30

-ha highlightamt ... HIGHLIGHTAMT is the highlight amount. Values are integers between 0 and 100. The default=30

-b bri ... BRI is the percent change in brightness. Values are integers between -100 and 100. The default=0 (no change)

-c con ... CON is the percent change in contrast. Values are integers between -100 and 100. The default=0 (no change)

-s sat ... SAT is the percent change in saturation. Values are integers between -100 and 100. The default=0 (no change)

-h hue ... HUE is the percent change in hue. Values are integers between -100 and 100. The default=0 (no change)

-m method ... METHOD specifies the order of shadow and hightlight processing. The choices are: SH (shadow first) or HS (highlight first). The default=SH

-p processing ... PROCESSING specifies where to adjust the brightness and contrast. The choices are: pre (for preprocessing), post (for postprocessing) or both (for both places). The default=both

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

Arguments:
-sc gold -sa 30 -hc skyblue -ha 30 -m HS

Arguments:
-sc gold -sa 30 -hc skyblue -ha 30 -m SH

 

Arguments:
-sc gold -sa 30 -hc skyblue -ha 30 -m HS -c 10 -s -40

Arguments:
-sc gold -sa 30 -hc skyblue -ha 30 -m SH -c 20 -s -40

 

Arguments:
-sc red -sa 30 -hc skyblue -ha 30 -m HS

Arguments:
-sc red -sa 30 -hc skyblue -ha 30 -m SH

 

Arguments:
-sc gold -sa 30 -hc pink -ha 30 -m HS

Arguments:
-sc gold -sa 30 -hc pink -ha 30 -m SH



Example 2

Original Image

Arguments:
-sc gold -sa 30 -hc palevioletred1 -ha 30 -m HS -c 20 -s -40

 

Arguments:
-sc gold -sa 30 -hc palevioletred1 -ha 30 -m SH -c 20 -s -40



What the script does is as follows:

  • For method=HS, composites the image with the specified highlight color using
    -compose lighten for the highlights and then composites the result with the
    other specified color using -compose darken for the shadows
  • For method=SH, reverses the order of processing

This is equivalent to the following IM commands:

  • sat=$((sat+100))
  • hue=$((hue+100))
  • if [ "$proc" = "pre" ]; then
    bcproc1="-brightness-contrast $bri,$con"
    bcproc2=""
    elif [ "$proc" = "post" ]; then
    bcproc1=""
    bcproc2="-brightness-contrast $bri,$con"
    elif [ "$proc" = "both" ]; then
    bcproc1="-brightness-contrast $bri,$con"
    bcproc2="-brightness-contrast $bri,$con"
    fi
  • convert $infile $bcproc1 -modulate 100,$sat,$hue $tmpA1
  • if [ "$method" = "SH" ]; then
    if [ "$samt" != "0" ]; then
    convert $tmpA1 \
    \( +clone -fill "$scolor" -colorize 100% -alpha set -channel A -evaluate set $samt% +channel \) \
    -compose lighten -composite $tmpA1
    fi
    if [ "$hamt" != "0" ]; then
    convert $tmpA1 \
    \( +clone -fill "$hcolor" -colorize 100% -alpha set -channel A -evaluate set $hamt% +channel \) \
    -compose darken -composite $tmpA1
    fi
    elif [ "$method" = "HS" ]; then
    if [ "$hamt" != "0" ]; then
    convert $tmpA1 \
    \( +clone -fill "$hcolor" -colorize 100% -alpha set -channel A -evaluate set $hamt% +channel \) \
    -compose darken -composite $tmpA1
    fi
    if [ "$samt" != "0" ]; then
    convert $tmpA1 \
    \( +clone -fill "$scolor" -colorize 100% -alpha set -channel A -evaluate set $samt% +channel \) \
    -compose lighten -composite $tmpA1
    fi
    fi
  • convert $tmpA1 $bcproc2 $outfile