--- title: "imagemagik .png to .jpg with white background" seo_description: "snippet explaining how to use imagemagik to covert images from .png .jpg and make the transparent parts white" date: 2022-03-03T21:31:00+01:00 draft: false snippet_types: - imagemagik --- Working on some .png map files today. I needed to covert them to small .jpg's for uses in [Oblastle](https://oblastle.fun). Problem being by default the transparent part fills into to black. Here is how to make it white: ```shell $ ls us-ak.png us-al.png us-ar.png us-az.png us-ca.png $ for file in *.png ; do magick mogrify -format jpg -resize '500' -background white -flatten $file; done $ ls us-ak.png us-ak.jpg us-al.png us-al.jpg us-ar.png us-ar.jpg us-az.png us-az.jpg us-ca.png $ rm ./*.png ``` The important bit being **-background white -flatten**. [source](https://stackoverflow.com/questions/7943711/change-the-background-of-an-image-in-image-magick)