Page 1 of 1

Converting a grayscale image to a colored image

Posted: 2011-05-11T13:18:47-07:00
by troyd1
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?

Re: Converting a grayscale image to a colored image

Posted: 2011-05-11T14:26:58-07:00
by fmw42
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

Posted: 2011-05-11T15:43:26-07:00
by troyd1
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.

Re: Converting a grayscale image to a colored image

Posted: 2011-05-11T17:25:20-07:00
by fmw42
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

Re: Converting a grayscale image to a colored image

Posted: 2011-05-11T19:32:18-07:00
by troyd1
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.

Re: Converting a grayscale image to a colored image

Posted: 2011-05-11T19:43:59-07:00
by fmw42
Did the +level-colors blue,white apply to both?
yes, IM will process any number of input images by the same command (except for commands that combine images) unless you use parens.

see
http://www.imagemagick.org/Usage/basics/#cmdline
http://www.imagemagick.org/Usage/basics/#image_seq