I wolud fill - dinamically - another color at the place of a specific color... In other words I want use the "fill" tool of common grapfhic programs using imagemagick.
For example this image has two colors: black and white.. I would transform black to red.. to green.. to... another color
Thanks!! (sorry my english)
How can I replece a color into a image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How can I replece a color into a image?
The easiest way to change from black and white to any other colors is to use Anthony's new +level-colors, for example:kali wrote:I wolud fill - dinamically - another color at the place of a specific color... In other words I want use the "fill" tool of common grapfhic programs using imagemagick.
For example this image has two colors: black and white.. I would transform black to red.. to green.. to... another color
Thanks!! (sorry my english)
convert bw_image.jpg +level-colors red,blue rb_image.jpg
This will convert black to red and white to blue. You can assign any valid IM colors.
see
http://www.imagemagick.org/Usage/color/#level_plus
http://imagemagick.org/script/color.php
Re: How can I replece a color into a image?
Use the -opaque option. Here's an example. http://www.imagemagick.org/Usage/color/#opaque
Re: How can I replece a color into a image?
rmagick wrote:Use the -opaque option. Here's an example. http://www.imagemagick.org/Usage/color/#opaque
Thank your reply
I have solve using: convert mucca.jpg -fuzz 30% -fill red -opaque black balloon_red.gi
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How can I replece a color into a image?
DO NOT USE -opaque This method only changes ONE exact or near-exact color (or NOT (+ form) that color) to another color without regard to color shades and anti-aliasing.
As given previously you can use the greyscale to color gradient replacement using +level-colors or turn white into transparency (negate to make black transparent) and set the other color using -alpha shape
given your original image as "cow.jpg"
This generates a red on white cow, without edge aliasing problems!
See IM examples Level change by color
You will definatally NOT get such a 'clean' color change using -opaque
As given previously you can use the greyscale to color gradient replacement using +level-colors or turn white into transparency (negate to make black transparent) and set the other color using -alpha shape
given your original image as "cow.jpg"
This generates a red on white cow, without edge aliasing problems!
Code: Select all
convert cow.jpg +level-colors red, cow_red.jpg
You will definatally NOT get such a 'clean' color change using -opaque
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/