aez
aez

Reputation: 2396

Changing a pixel's alpha value with imagemagick

I have an image with some opaque white pixels (rgba = FFFFFFFF). I want to change those pixels to a different color with a different transparency, say rgba = 33333355.

I use

convert test.png -fuzz 1% -alpha set -fill '#33333355' -opaque '#ffffffff' test2.png

The pixel's colors are changed properly, but not the alpha values, so I get new pixels with rgba = 333333FF !

Why can I change the rgb value, but not the alpha value?? How can I change the alpha value also?

Thanks

Upvotes: 1

Views: 1495

Answers (1)

emcconville
emcconville

Reputation: 24419

Your just missing the -channel option. I believe the default channel value is 'RGBK,sync'; however, your attempting to alter pixels as 'RGBA'.

convert test.png \
    -fuzz 1% \
    -alpha set \
    -channel RGBA \
    -fill '#33333355' \
    -opaque '#ffffffff' \
    test2.png

Upvotes: 2

Related Questions