Search code examples
image-processingcommand-lineimagemagick

ImageMagick: Mass extract alpha from png \ Combine files back


I can extract alpha from 1 file at time with this command

convert Alpha.png -alpha extract Alpha_alpha2.png

How to use it with .bat to mass extract all png in folder? And what command would be to add alpha back to image?


Solution

  • You could use mogrify to extract the alpha channel from all images in a folder in Imagemagick.

    mogrify -path path_to/new_folder -format png -alpha extract *.png
    

    That would put all the alpha channels into an empty (but existing) new folder with the name of the input image

    To add an alpha channel onto an image, one at a time, you would do:

    convert image.png alpha.png -alpha off -compose copy_opacity -composite result.png