Page 1 of 1

Replace color to same semi-transparent color

Posted: 2009-07-09T07:35:58-07:00
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

Re: Replace color to same semi-transparent color

Posted: 2009-07-09T09:40:15-07:00
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

Re: Replace color to same semi-transparent color

Posted: 2009-07-10T01:03:51-07:00
by kserradell
fmw42,

thank you very much.

that's what I was looking for.

thanks again for you help !!!

KiM