Replace transparency in PNG image with white background
alpha-transparency, imagemagick, png
Solution
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`)
Problem
I have a PNG image with an alpha channel (i.e. transparency), and I need to create versions with the image layer composed onto a white background. I want to use a scriptable command using a CLI tool such as Image Magick to directly convert PNG to PNG losslessly. An example of a non-working Image Magick command which results in an error is: ``` convert input.png -background white -flatten output.png ```