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. |
Changes one color to another color in an image. |
last modified: September 13, 2023
USAGE: replacecolor [-i icolor] [-o ocolor] [-f fuzzval ] [-g gain] [-t thresh] [-b brightness] [-s saturation] [-c colormode] infile [outdir]
-i ... icolor ....... color in the input image to be replaced; PURPOSE: To change one color to another color in an image. DESCRIPTION: REPLACECOLOR changes one color to another color in an image by modifying the input color hue to the desired output color hue and adjusting the saturation and brightness. ARGUMENTS: -i icolor ... ICOLOR is the color in the input image to be changed. Any valid opaque IM color is allowed. The default=blue -o ocolor ... OCOLOR is the replacement color for the output image. Any valid opaque IM color is allowed. The default=red -f fuzzval ... FUZZVAL on each side of the old color for the range of input hues to be recolored. Values are 0<=float<=180 degrees. The default=40. -g gain ... GAIN on color conversion. Values are integers>=0. The default=100. -t thresh ... THRESHOLD value in percent for forcing low saturation colors to zero saturation, i.e. converts near gray (white through black) to pure gray. Values are floats>=0. The default=0. -b brightness ... BRIGHTNESS is the percent additional change in brightness. Values are integer>=-100. The default=0 (no change). -s saturation ... SATURATION is the percent additional change in saturation. Values are -100<=integer<=100. The default=0 (no change). -c colormode ... COLORMODE in which to do processing. The choices are: hsv, hsl, hsi or hcl. The default=hsv. REQUIREMENTS: IM 6.5.3-7 or higher, so that -modulate uses HSL and not HSB colorspace. 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. |
Example 1 -- Variation in Fuzz |
Original |
Arguments: |
Arguments: |
Arguments: |
Example 2 -- Variation in Gain |
Original |
Arguments: |
Arguments: |
Arguments: |
Example 3 -- Variation in Color |
Original |
Arguments: |
Arguments: |
What the script does is as follows for border=black at the top/bottom edges:
This is equivalent to the following IM commands
|