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. |
Applies a color level transformation to an image channel-by-channel. |
last modified: December 03, 2023
USAGE: levelcolors [-c channels] [lowcolorxhighcolor] infile outfile
-c .... channels .......... channels are the sequence of channels to be PURPOSE: To apply a color level transformation to an image channel-by-channel. DESCRIPTION: LEVELCOLORS apply a color level transformation to an image using the -level operator on a channel-by-channel basis using color values specified to be mapped to black and to white. ARGUMENTS: -c channels ... CHANNELS are the sequence of channels to be processed. Choices are: any combinations of 1 to 4 of r,g,b,a such rgb or rgba. For grayscale images with alpha, specify r if you do not want the alpha channel processed. Specify rgb if you want to colorize a grayscale image. The default is all available channels in the image. IMPORTANT: if channels are specified, then it must be before lowcolorxhighcolor in the command line. lowcolorxhighcolor ... LOWCOLORxHIGHCOLOR are the two colors to be mapped to black and white respectively on a channel-by-channel basis. If no color values are provided, then the output will be the same as the input. If lowcolor is left off (value specified as xHIGHCOLOR), then low color of rgba(0%,0%,0%,0) (opaque black) will be used. If highcolor is left off (value specified either as LOWCOLOR or xLOWCOLOR), then highcolor will be set to the complement of the lowcolor, i.e. (QuantumRange minus lowcolor). Colors may be specified in an valid IM format: rgb(...), rgba(...), hexcolor values or color names. Use of color names assumes the name does not include the letter "x". If not using color names, you must enclose this argument in quotes. Alpha values may be included. Note: graya(...) color specifications do not seem to be working to generate any amount of transparency prior to IM 6.4.1-8. See http://imagemagick.org/script/color.php NOTE: infile is limited to single channel gray or three channel rgb with or without an alpha channel. CMYK is excluded. The alpha channel will not be modified, but will be tranferred from input to output. 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. |
Color Transformations Of An Image |
|
Original Image |
No Change |
Original Image |
Invert Colors |
Original Image |
Invert Colors |
Original Image |
Invert Red Channel Only |
Original Image |
Increase Contrast |
Original Image |
Increase Brightness |
Original Image |
Decrease Brightness |
Original Image |
Increase Brightness Of Green Channel Only |
Original Image |
Negate Alpha Channel |
Original Image |
Threshold To Pure White |
Original Image |
Threshold To Pure Black |
Grayscale Colorization |
|
Original Image |
Red Gradient |
Original Image |
Blue To Red Gradient |
What the script does is as follows:
This is equivalent to the following IM commands to negate a RGB image:
|