Fill alpha channel with a constant?

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
rling
Posts: 7
Joined: 2007-10-07T16:21:15-07:00

Fill alpha channel with a constant?

Post by rling »

Hi, is there a quick way to fill an image's alpha channel with a constant? -fx and -recolor are overkill and are quite slow. i would like to do what -dissolve does but 'convert' doesnt support it. thanks
rling
Posts: 7
Joined: 2007-10-07T16:21:15-07:00

Re: Fill alpha channel with a constant?

Post by rling »

I've just noticed there is a -compose operator, copy-opacity, which might work. I would have to create a canvas using xc:, with a solid color and the required opacity and the size of the image whose alpha channel I want to set, and composite it onto the image with copy-opacity. The downside is I need to know the size of the image in advance which is really a pain... oh well back to the documentation
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Fill alpha channel with a constant?

Post by anthony »

Easy way is to just set all that channels values...

Code: Select all

    -channel A -evaluate set 50% +channel
will replace all alpha/matte channel values with a 50% transparency.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply