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.

COLORFILTER


Applies a photographic color filters to an image.

Download Script

last modified: December 15, 2018



USAGE: colorfilter [-m method] [-c color] [-d density] infile [maskfile] outfile
USAGE: colorfilter [-h or -help]

-m ... method .... method of applying color filter; choices are 1 or 2;
.................. 1 is blending; 2 is adding; default=1
-c ... color ..... desired filter color; any valid IM opaque color
.................. value is valid as well as the following special colors:
.................. warming85, warming81, cooling80, cooling82, sepia,
.................. underwater, t1000, t1850, t3000, t4100, t5000, t8000,
.................. t13000, t21000, t40000; default=red
-d ... density ... density of filter; 0<=integer<=100; 0 is no change;
.................. 100 is most change; default=25

Maskfile is any grayscale image the same size as the infile

PURPOSE: To apply a photographic color filter to an image.

DESCRIPTION: COLORFILTER applies a photographic color filter to an image. Optionally, a grayscale mask file can be provided to limit the region to be processed. This script simulates the Photoshop Photo Filter function.

ARGUMENTS:

-m method ... METHOD of applying color filter. Choices are 1 or 2. 1 is blending and 2 is adding. The default=1.

-c color ... COLOR of desired filter. Any valid IM opaque color value is valid as well as the following special colors: warming85, warming81, cooling80, cooling82, sepia, underwater, t1000, t1850, t3000, t4100, t5000, t8000, t13000, t21000, t40000. The t-filters correspond to the blackbody radiation color of the given color temperature. The default=red.

-d density ... DENSITY of filter. Values are integers between 0 and 100. 0 is no change and 100 is the most change. The default=25

Maskfile is any grayscale image the same size as the infile. The filter is applied most where the mask is white.

REQUIREMENTS: IM 6.7.9.0 or higher due to a change in -compose luminize to use the new HCL colorspace rather than the older HSL colorspace.

REFERENCES:
http://en.wikipedia.org/wiki/Color_temperature
http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html
http://web.archive.org/web/20091028192325/http://www.geocities.com/cokinfiltersystem/color_corection.htm

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


Table Of Special Colors

Color Name

Description

Color Temperature

Color

t1000

 

1000 deg

#ff3300

t1850

sunrise, sunset or candle flame

1850 deg

#ff8000

warming85

photoshop filter

 

#ec8a00

warming81

photoshop filter

 

#ebb113

t3000

incandescent light

3000 deg

#ffb969

t4100

moon light

4100 deg

#ffd7a6

t5000

horizon daylight

5000 deg

#ffe7cc

sepia

photoshop filter

 

#ac7a33

underwater

photoshop filter

 

#00c2b1

t8000

 

8000 deg

#e5e9ff

t13000

 

13000 deg

#beceff

t21000

clear blue northern sky

21000 deg

#acc0ff

t40000

 

40000 deg

#a1b7ff

cooling82

photoshop filter

 

#00b5ff

cooling80

photoshop filter

 

#006dff



Example 1 - Method 1 vs Method 2

Original
(http://us.cdn2.123rf.com/168nwm/clairev/clairev0905/clairev090500070/4874152-cartoon-sailboat-on-white-background--vector-illustration.jpg)

Arguments:
-m 1 -c red -d 25

Arguments:
-m 1 -c red -d 50

Arguments:
-m 1 -c red -d 75

Arguments:
-m 1 -c red -d 100

Arguments:
-m 2 -c red -d 25

Arguments:
-m 2 -c red -d 50

Arguments:
-m 2 -c red -d 75

Arguments:
-m 2 -c red -d 100



Example 2 - Warming vs Cooling Filters

Original

Arguments:
-m 1 -c warming85 -d 25

Arguments:
-m 1 -c warming85 -d 50

Arguments:
-m 1 -c warming85 -d 75

Arguments:
-m 1 -c warming85 -d 100

Arguments:
-m 1 -c cooling80 -d 25

Arguments:
-m 1 -c cooling80 -d 50

Arguments:
-m 1 -c cooling80 -d 75

Arguments:
-m 1 -c cooling80 -d 100



Example 3 - Warming with Transparency

Original
(http://www.clker.com/clipart-sailboat.html)

>

Arguments:
-m 1 -c warming85 -d 25

Arguments:
-m 1 -c warming85 -d 50

Arguments:
-m 1 -c warming85 -d 75

Arguments:
-m 1 -c warming85 -d 100



Example 4 - Warming and Cooling without and with Simple Gradient Mask
(http://upload.wikimedia.org/wikipedia/commons/d/d0/Barns_grand_tetons.jpg)
(filter is applied most where mask is white)

Original

Mask

Arguments:
Without Mask
-m 1 -c warming85 -d 25

With Mask
Arguments:
-m 1 -c warming85 -d 25

Arguments:
Without Mask
-m 1 -c cooling80 -d 25

With Mask
Arguments:
-m 1 -c cooling80 -d 25



Example 5 - Warming and Cooling without and with Modified Gradient Mask
(filter is applied most where mask is white)

Original

Mask

Arguments:
Without Mask
-m 1 -c warming85 -d 25

Arguments:
With Mask
-m 1 -c warming85 -d 25

Arguments:
Without Mask
-m 1 -c cooling80 -d 25

Arguments:
With Mask
-m 1 -c cooling80 -d 25



What the script does is as follows:

  • Colorizes a copy of the image
  • Does a -composite luminize between the original and colorized images

This is equivalent to the following IM commands for method=1

  • convert $infile -colorspace RGB \
    \( -clone 0 -fill "$color" -colorize $density% \) \
    +swap -compose luminize -composite -colorspace sRGB \
    $outfile