imagemagik .png to .jpg with white background - 03-03-22

Working on some .png map files today. I needed to covert them to small .jpg’s for uses in Oblastle. Problem being by default the transparent part fills into to black. Here is how to make it white:

$ 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

\- [ imagemagik ]