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?".
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-10-20T14:56:29-07:00
Well, let's say I have this picture:
Let's assume I want to change all the gray color in this picture to plain black.
Is there a command to have imagemagick change all grey of this image (preferableby using grey [Hex: C8C8C8] to black [Hex: 000000] ?
I ask for a way to use the color value itself so I could use this code on more complicated examples in future.
[spoiler]
For example changing a certain yellow tone in this image to a special orange or something [/spoiler]
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-10-20T15:51:40-07:00
Is this also possible by using the HexCodes I mentioned
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-10-20T16:28:17-07:00
Code: Select all
convert Clipboard01.png -level-colors #c8c8c8,white p.png
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-10-20T17:55:11-07:00
Code: Select all
convert Clipboard01.png -fuzz 10% -fill black -opaque "#c8c8c8" result.png
change the fuzz value to whatever works best
anthony
Posts: 8883 Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia
Post
by anthony » 2013-10-21T22:11:50-07:00
That latter (using -opaque) is probably not good as the image is full of shades of gray, and -opqaue is a boolean (all or nothing) type operator.
-level-colors will give ber find control over the transformation. -level will give grayscale control -normalize and -auto-level will automatically maximise contrast (though with different 'level' selection)
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-10-22T11:33:12-07:00
Ok, this works really well. Thanks.
Another question:
If I wanted to change from one hex code to a specific other one.
What woudl I have to change in that code of yours ?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-10-22T11:41:08-07:00
Code: Select all
convert image -fuzz XX% -fill "newhexcode" -opaque "oldhexcode" result
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-10-22T12:12:54-07:00
Thanks ! Just what I was looking for!
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-10-22T12:38:56-07:00