HUE: Converting .gif logo color to specified RGB value

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ricardo_mano

HUE: Converting .gif logo color to specified RGB value

Post by ricardo_mano »

I would like to be able to convert a logo for a website (e.g. help icon) to a different color, specified on input. I am able to gain the desired effect using the '-modulate' operator, but the outcome is determined as a rotation of color values.

Basic example: the current logo color is green, and the user decides it should be purple. The user enters purple, along with the logo. The result is a new logo which is now purple.

I have thought about using masks and transparency, and changing the original image to black and white. Is this a good route to explore, or is there an easier method?

Thankyou for your help.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: HUE: Converting .gif logo color to specified RGB value

Post by anthony »

convert the logo to a greyscale version. then use -tint (set grey colors) or +level-colors (set black/white gradient) to color the image to ANY color by name or value!

See IM Examples, Color Modifications

Level Adjustment by Color
http://www.imagemagick.org/Usage/color/#level-colors

Midtone Color Tinting
http://www.imagemagick.org/Usage/color/#tint
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ricardo_mano

Re: HUE: Converting .gif logo color to specified RGB value

Post by ricardo_mano »

Thanks for that Anthony, I'll take a closer look at those operators.
ricardo_mano

Re: HUE: Converting .gif logo color to specified RGB value

Post by ricardo_mano »

anthony wrote:convert the logo to a greyscale version. then use -tint (set grey colors) or +level-colors (set black/white gradient) to color the image to ANY color by name or value!

See IM Examples, Color Modifications

Level Adjustment by Color
http://www.imagemagick.org/Usage/color/#level-colors

Midtone Color Tinting
http://www.imagemagick.org/Usage/color/#tint
I've had a quick go at manipulating the .gif by the above method and it seems that not enough of the 'secondary' colour are preserved. i.e I want to define the main color, not the entire icon (see the handle in the example below). Having said that, It wouldn't matter too much, but I would need to get the result a little darker - with more contrast.

Here is an example of the different methods.

The input image.

Image

Conversion using hue offset of 10 (-modulate 100,100,10)

Image

Conversion using the above method (grayscale then recoloring)

Image

Just thought I'd give some feedback.. and to see if anyone has any other suggestions. I will look into the documentation more tomorrow for inspiration, but for now it's very late (UK time). Thanks again for any help.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: HUE: Converting .gif logo color to specified RGB value

Post by anthony »

For this image you woyld make sure the circle and the magnifying glass is black, You can then use -tint to tint the grey parts.

However I agree modulate would probably be the better method for the image in question.

NOTE 100,100,100 is NO change.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply