How can I convert a folder of .pngs to .jpgs while setting the background color?

The JPEG format does not support transparency -- therefore maintaining the transparent backgrounds is not possible if you want to (or have to) use the JPEG format. See Wikipedia for an overview of the capabilities of different image formats.

Note that the JPEG 2000 does indeed support transparency, but it is much less common than the JPEG format. It depends on your use case whether this is a viable alternative.


To your second question:

To specify the background color when converting your images you can use the -fill option:

mogrify -quality 100 -format jpg -fill "#FF0000" -opaque none *.png

Using -background provides similar results. Dont forget the -opaque none.


I'm sorry there is no way, jpeg format doesn't support an alpha channel so you can't have transparency.