Replace color to same semi-transparent color

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
kserradell

Replace color to same semi-transparent color

Post by kserradell »

Hello,

Sorry if the question is too simple but i've been trying to solve it without success.

This is my problem.

There's an image with some red regions (red is the example, but I want to set this color each time).

I want to get a new image with these same red regions, but with 50% transparent.

I use the following command:

Code: Select all

 convert red.png -matte -fill '#00000050' -draw 'matte 0,0 replace' semi_red.png
It works but only because there is a red color on 0,0.

How can I set a different color each time ??? Using 'green', 'red' or #0000FF ???

Thanks a lot !!!

KiM
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replace color to same semi-transparent color

Post by fmw42 »

This will change white to half transparent white in the logo image so you can test it. You can change the color to any other rgba color. Note you must use .png for output as gif only supports binary transparency and jpg does not support any transparency.

convert logo: -channel rgba -matte -fill "rgba(255,255,255,0.5)" -opaque "rgb(255,255,255)" logot.png

If you want to include colors that are not exact, but nearby, then add -fuzz XX%

see
http://www.imagemagick.org/script/color.php
kserradell

Re: Replace color to same semi-transparent color

Post by kserradell »

fmw42,

thank you very much.

that's what I was looking for.

thanks again for you help !!!

KiM
Post Reply