Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set background color in ImageMagick

📅 2014-Nov-19 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ background, imagemagick ⬩ 📚 Archive

PDF, SVG, PNG and many other image formats can have a transparent background. Sometimes, you might want to set the background color in image files. This can be done easily using the -background and -flatten options.

For example, to convert a PDF to JPG file and set the background color in the resulting file to white:

$ convert foo.pdf -background "#FFFFFF" -flatten foo.jpg

Tried with: ImageMagick 6.7.7.10 and Ubuntu 14.04