Replace transparency in PNG images with white background

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 Magick “convert” operations, but either nothing happens at all or I get an error. I don’t want to go to an intermediate JPG form because I don’t want the artifacts. Of course it’s easy to do this in Gimp or Photoshop or whatever, but I’d really rather script it from the command line because there are many of these things.

An example of a non-working Image Magick command is:

convert img1.png -background white -flatten img1-white.png

That results in an error.

Thanks!

17 Answers
17

Leave a Comment