Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i add an alpha channel to this image using ImageMagick

I tried adding an alpha channel to this image image without alpha channel using this command

convert az.png -alpha set temp.png

The resulting temp.png still has no alpha channel. What am I doing wrong?

The image was obtained from http://flagpedia.net/data/flags/mini/az.png

like image 505
Mike Hogan Avatar asked Nov 08 '25 17:11

Mike Hogan


1 Answers

By default ImageMagick will "optimize" the output, removing the alpha channel if it's all-opaque, and perhaps converting it to indexed format if fewer than 256 colors are present. You can force ImageMagick to retain the alpha channel by using "png32:" prefix on the output filename:

convert az.png png32:temp.png

or with the current ImageMagick release version 7

magick az.png png32:temp.png

resulting in

pngcheck *.png
OK: az.png (40x20, 24-bit RGB, non-interlaced, 92.7%).
OK: temp.png (40x20, 32-bit RGB+alpha, non-interlaced, 87.0%).
like image 88
Glenn Randers-Pehrson Avatar answered Nov 11 '25 08:11

Glenn Randers-Pehrson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!