Imagemagick: remove alpha component (replace all intermediate alpha pixel with solid pixel)

前端 未结 2 1429
难免孤独
难免孤独 2020-12-31 01:18

To solve Android build issue I need to replace all intermediate alpha pixel with solid pixel (leaving transparent background as is).

How to that with ImageMagick or o

相关标签:
2条回答
  • 2020-12-31 02:00

    To remove alpha channel from all pictures in the folder (f.ex. all .png files) I use following command (in terminal on macOS):

    for file in *.png; do convert $file -alpha deactivate; done
    

    Unfortunately, none of any other solution given in this thread worked for me.

    0 讨论(0)
  • 2020-12-31 02:01

    To remove the alpha channel from single image use this command:

    convert input.png -alpha off output.png
    

    To remove the alpha channel from all images inside a folder, make use find to first find all PNG files, and then run 'm through convert:

    find . -name "*.png" -exec convert "{}" -alpha off "{}" \;
    

    Please test on a COPY of your files to be sure.

    ...

    see dialog below, and the answer is based on that "we need to remove alpha that is not 255"

    convert input.png -channel A -threshold 254 output.png
    

    and for batch

    mkdir batch
    FOR %G IN (*.png) DO convert %G -channel A -threshold 254 batch\%G
    
    0 讨论(0)
提交回复
热议问题