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
Non-command line option: open the PNG file in Windows Paint and click Save.
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
here's how to replace the same image in all folders in a directory with white instead of transparent:
mogrify -background white -flatten */*.png
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.
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
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 {} \;