You need to use -extent to set the canvas size immediately after you have resized, and the newly created area will be filled with what you set -background to.
So, if you want the padding to be magenta, do the following:
convert image.png -resize 100x100 -background "rgb(255,0,255)" -extent 100x100 out.png
If you want your image to appear βin the middleβ of the output image, if you are evenly spaced around the sides, add -gravity center as follows:
convert image.png -resize 100x100 -gravity center -background "rgb(255,0,255)" -extent 100x100 out.png
So, if we start with a wide blue image, that is 300x100 and we have no chance to choose the right square, as shown below:

and we will resize it as follows:
convert image.png -resize 100x100 -gravity center -background "rgb(255,0,255)" -extent 100x100 out.png
we get it

Mark setchell
source share