Replace transparency in PNG images with white background

后端 未结 16 641
再見小時候
再見小時候 2020-11-29 14:48

I\'ve got some PNG images with transparency, and I need to create versions with the image layer composed onto a white background. I\'ve tried various things with Image Magi

相关标签:
16条回答
  • 2020-11-29 15:47

    Using -flatten made me completely mad because -flatten in combination with mogrify crop and resizing simply doesn't work. The official and for me only correct way is to "remove" the alpha channel.

    -alpha remove -alpha off (not needed with JPG)

    See documention: http://www.imagemagick.org/Usage/masking/#remove

    0 讨论(0)
  • 2020-11-29 15:48

    It appears that your command is correct so the problem might be due to missing support for PNG (). You can check with convert -list configure or just try the following:

    sudo yum install libpng libpng-devel
    
    0 讨论(0)
  • 2020-11-29 15:52

    This works for me:

    convert -flatten img1.png img1-white.png
    

    Documentation references:

    • -flatten command-line option
    • -layers command-line option (-flatten is equivalent to -layers flatten)
    0 讨论(0)
  • 2020-11-29 15:52

    The only one that worked for me was a mix of all the answers:

    convert in.png -background white -alpha remove -flatten -alpha off out.png
    
    0 讨论(0)
提交回复
热议问题