Creating image borders with ImageMagick convert
The command is:
convert -border 2x2 old.jpg new.jpg
This creates a new image (new.jpg) with a 2 pixel border from the image old.jpg.
To set the bordercolor to red, use this command:
convert -border 2x2 -bordercolor "#FF0000" old.jpg new.jpg