Converting a grayscale image to a colored image
Converting a grayscale image to a colored image
I have a grayscale image. I would like to convert it to another color, say blue. I would now want the black to be blue and the others to be shades of blue. How would I do that?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting a grayscale image to a colored image
troyd1 wrote:I have a grayscale image. I would like to convert it to another color, say blue. I would now want the black to be blue and the others to be shades of blue. How would I do that?
Please read viewtopic.php?f=1&t=9620 as you do not identify your version of IM nor platform. If your IM is not too old, then try
convert image +level-colors black,blue resultimage
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
Re: Converting a grayscale image to a colored image
Sorry, 6.6.9-7. q16 dynamic - window 2003 server
I tried some itteration using +level-color with promising results.
Here is my command:
convert -size 1650x1275 -density 300 xc:#ffff99 "c:\PCSHARE\PCGRAPHICS\ITWEB\REXFILES\BG_SC1_Design_03.png" +level-colors blue,white -composite -resize 20% c:\temp\graphics\finalgraphic.png
The graphic is actually a fancy border in grayscale.
The image is here: http://67.62.79.120/graphicstemp/BG_SC1_Design_03.png
After the composite, it does not have the ffff99 background, just white.
I also tried :
convert -size 1650x1275 -density 300 xc:#ffff99 "c:\PCSHARE\PCGRAPHICS\ITWEB\REXFILES\BG_SC1_Design_03.png" +level-colors blue,white -fill transparent -opaque white -composite -resize 20% c:\temp\graphics\finalgraphic.png
this gives me a black background.
Getting close, just not sure what to try next.
Thanks in advance for your help.
I tried some itteration using +level-color with promising results.
Here is my command:
convert -size 1650x1275 -density 300 xc:#ffff99 "c:\PCSHARE\PCGRAPHICS\ITWEB\REXFILES\BG_SC1_Design_03.png" +level-colors blue,white -composite -resize 20% c:\temp\graphics\finalgraphic.png
The graphic is actually a fancy border in grayscale.
The image is here: http://67.62.79.120/graphicstemp/BG_SC1_Design_03.png
After the composite, it does not have the ffff99 background, just white.
I also tried :
convert -size 1650x1275 -density 300 xc:#ffff99 "c:\PCSHARE\PCGRAPHICS\ITWEB\REXFILES\BG_SC1_Design_03.png" +level-colors blue,white -fill transparent -opaque white -composite -resize 20% c:\temp\graphics\finalgraphic.png
this gives me a black background.
Getting close, just not sure what to try next.
Thanks in advance for your help.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting a grayscale image to a colored image
sorry I misread about the black and thought you wanted to preserve it. You need parens to avoid recoloring your #ffff99 background and quotes around it also. Try
convert ( -size 1650x1275 xc:"#ffff99" ) ( BG_SC1_Design_03.png +level-colors blue,white ) -composite -resize 20% result.png
but put your full paths back in as I had your image in my home directory.
or better (simpler)
convert BG_SC1_Design_03.png +level-colors blue,white -background "#ffff99" -flatten -resize 20% result.png
convert ( -size 1650x1275 xc:"#ffff99" ) ( BG_SC1_Design_03.png +level-colors blue,white ) -composite -resize 20% result.png
but put your full paths back in as I had your image in my home directory.
or better (simpler)
convert BG_SC1_Design_03.png +level-colors blue,white -background "#ffff99" -flatten -resize 20% result.png
Re: Converting a grayscale image to a colored image
Thanks for the reply. The first option will work. I am confused though.
I thought that the way image magic worked was like a stack so that
convert -size 1650x1275 xc:"#ffff99" was the first "layer" and BG_SC1_Design_03.png would be the second layer so that +level-colors blue,white would on work on the BG_SC1_Design_03.png and then the -composite would lay BG_SC1_Design_03.png +level-colors blue,white on top of the canvas without even using the parens. Please explain where my logic went wrong. Did the +level-colors blue,white apply to both? Thanks again for your help.
I thought that the way image magic worked was like a stack so that
convert -size 1650x1275 xc:"#ffff99" was the first "layer" and BG_SC1_Design_03.png would be the second layer so that +level-colors blue,white would on work on the BG_SC1_Design_03.png and then the -composite would lay BG_SC1_Design_03.png +level-colors blue,white on top of the canvas without even using the parens. Please explain where my logic went wrong. Did the +level-colors blue,white apply to both? Thanks again for your help.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting a grayscale image to a colored image
yes, IM will process any number of input images by the same command (except for commands that combine images) unless you use parens.Did the +level-colors blue,white apply to both?
see
http://www.imagemagick.org/Usage/basics/#cmdline
http://www.imagemagick.org/Usage/basics/#image_seq