Change all pixels of a specific color to a semi-transparent

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
chad182

Change all pixels of a specific color to a semi-transparent

Post by chad182 »

Full Subject: Change all pixels of a specific color to a semi-transparent color

I have an image (obviously) and I want to change all of the white rgba pixels in the image to a semi-transparent rgba color (i.e. 210,210,210,0.5).

How can I accomplish this?

Thanks in advance!
Chad
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Change all pixels of a specific color to a semi-transpar

Post by fmw42 »

convert image -channel rgba -alpha on -fill "rgba(210,210,210,0.5)" -opaque white result

be sure to use png or gif or tiff as jpg does not support transparency


Presumably your image does not have transparency to begin with. If otherwise, then the approach needs to change for the transparency existing on the white parts.
Post Reply