Search code examples
imagemagick

change the background of an image in image magick


I am using this command for imagemagick to extend the size of an image and background to white

convert input.png -extent 495X320 -gravity center  -background white output.jpg

The size is doing extent but the background is black every time. I tried many methods but the same black is coming every time.So can some one help me how to solve this. Any help and suggestions will be highly appreciable.


Solution

  • The order is important here, use -background before -extent:

    convert input.png -background white -extent 495X320 -gravity center output.jpg