I tried adding an alpha channel to this image 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
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%).