Replace transparency in PNG images with white background

后端 未结 16 640
再見小時候
再見小時候 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:32

    Non-command line option: open the PNG file in Windows Paint and click Save.

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

    This is not exactly the answer to your question, but I found your question while trying to figure out how to remove the alpha channel, so I decided to add this answer here:

    If you want to remove alpha channel using imagemagick, you can use this command:

    mogrify -alpha off ./*.png
    
    0 讨论(0)
  • 2020-11-29 15:39

    here's how to replace the same image in all folders in a directory with white instead of transparent:

    mogrify -background white -flatten */*.png

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

    I needed either: both -alpha background and -flatten, or -fill.

    I made a new PNG with a transparent background and a red dot in the middle.

    convert image.png -background green -alpha off green.png failed: it produced an image with black background

    convert image.png -background green -alpha background -flatten green.png produced an image with the correct green background.

    Of course, with another file that I renamed image.png, it failed to do anything. For that file, I found that the color of the transparent pixels was "#d5d5d5" so I filled that color with green:

    convert image.png -fill green -opaque "#d5d5d5" green.png replaced the transparent pixels with the correct green.

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

    It's -alpha off, NOT -alpha remove! iOS app store upload fails when there is an alpha channel in any icon!!

    Here's how to do it: mogrify -alpha off *.png

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

    I saw this question and answers which really help me but then I was needed to do it for a lot of files, So in case you have multiple images (PNG images) in one folder and you want to do it for all:

    find ./ -name "*.png" -exec convert {} -flatten {} \;
    
    0 讨论(0)
提交回复
热议问题