Page 1 of 1

How to replace color with another

Posted: 2009-07-22T04:47:26-07:00
by NyzeAustria
Hello Community

I have a base image that looks like that

OrigImage

I need to change the color of this arrow based on a selection from a color picker.
Basicly i tried this with Photoshop and the result looks like this. I used a simple color overlay with RGB(255,0,0)

Result Image

My goals is to do this with IM so i looked up the tinting samples which uses -colorize. But -colorize just blends the image with a fill color rather than overlay the base with the new color. I don't know how to get this work that it looks like in Photoshop.

Re: How to replace color with another

Posted: 2009-07-22T08:59:56-07:00
by Bonzo

Re: How to replace color with another

Posted: 2009-07-22T09:42:43-07:00
by fmw42
try -modulate

Re: How to replace color with another

Posted: 2009-07-22T18:09:42-07:00
by anthony

Re: How to replace color with another

Posted: 2009-07-23T00:49:24-07:00
by NyzeAustria
Thx

I looked at the samples. But how can i modulate my image to an exactly value in RGB like
R:101 G:237: B159. Playing with the HUE value from 0 to 360 gives only 360 possible colors. I don't understand how this exactly works. I am a really noob to graphics.

Re: How to replace color with another

Posted: 2009-07-23T11:16:59-07:00
by fmw42
you will have to convert RGB colors to HSL or HSB colors. There are many online tools that will do that for you. You provide the RGB and it tells you the HSL or HSB. See for example:

http://serennu.com/colour/hsltorgb.php
http://web.forret.com/tools/color.asp

You can do a Google search and probably find others or even tools to download. For example many imaging tools like photoshop, etc have these built in.

Also note that in IM, you can provide floating point values to -modulate.

Re: How to replace color with another

Posted: 2009-07-23T17:17:45-07:00
by anthony
NyzeAustria wrote:Thx
Playing with the HUE value from 0 to 360 gives only 360 possible colors. I don't understand how this exactly works. I am a really noob to graphics.
The number is floating point, not integer! and it goes from 0 to 200 (the results is the same for those two values) with a value of 100 for no change.

Read the 'Usage Guide' link!

Re: How to replace color with another

Posted: 2009-07-23T17:20:41-07:00
by anthony
Another way is to convert the image provided to a grayscale!
You can then tint that grayscale so that anything that was pure 50% gray becomes the exact color specified using -fill {color} -tint 100

See 'Tint' on the same IM Examples page
http://www.imagemagick.org/Usage/color/#tint


Hmmm looking at the operator again, it seems I was wrong, pure grays do not become the exact color! I will need to study this further, and either get that fixed, or find out what it really is going.

In the mean time their are DIY alternatives.

Re: How to replace color with another

Posted: 2009-08-18T03:12:06-07:00
by NyzeAustria
Is there still no solution for this? Don't know how to get this work!

Re: How to replace color with another

Posted: 2009-08-18T09:56:29-07:00
by fmw42
I believe we have given you many solutions. If we have misunderstood your problem, please clarify with examples of what you have and what you need. It does not have to be the same solution as PS, but simply get you the same kind of results.

The easiest way is

convert image -colorspace gray +level-colors color1,color2 output

see

http://www.imagemagick.org/Usage/color/#level-colors
http://www.imagemagick.org/Usage/color/#tinting