converting one color to another with command line - didn't w

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
psydev
Posts: 3
Joined: 2012-05-11T11:32:14-07:00
Authentication code: 13

converting one color to another with command line - didn't w

Post by psydev »

Hi, guys. Hoping you could help with a problem I'm having
I am trying to convert certain colors in a picture to another color. When I tried the convert command nothing happened, however. I tried this as a simple test, to convert black to white, but it didn't do anything:

convert test.png -fill "#000000" -opaque "#ffffff" test2.png

Can anyone tell me what I'm doing wrong?
Thanks,
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: converting one color to another with command line - didn

Post by fmw42 »

your image is probably not uniform colors, so you probably need to use -fuzz XX% to catch similar (or near) colors.

it would really help if you could post a link to your input image. it would make it easier to help pinpoint the issue.
psydev
Posts: 3
Joined: 2012-05-11T11:32:14-07:00
Authentication code: 13

Re: converting one color to another with command line - didn

Post by psydev »

Hey,
Here is the image. It seems pretty uniform in the blackness. I wanted to test changing the black to white since it would be dramatic and noticeable. I wanted to change the reds to some yellows.
http://i.imgur.com/sDE32.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: converting one color to another with command line - didn

Post by fmw42 »

This command works perfectly fine for me on IM 6.7.6.9 Q16 Mac OSX Snow Leopard:

convert sDE32.png -fill white -opaque black sDE32_proc.png

The black is converted to white.

Your comand was backwards, that is, trying to convert white to black and there is no pure white in your image. The brightest gray was 252 and only 42 pixels at that value.


What version of IM are you using? If old, perhaps upgrade.
psydev
Posts: 3
Joined: 2012-05-11T11:32:14-07:00
Authentication code: 13

Re: converting one color to another with command line - didn

Post by psydev »

haha, thanks so much! Works great now. What a useful program!
Post Reply