Add borders



<?php  
$cmd = " \( input.jpg -resize 250x250 -bordercolor coral4 -border 1x1 \) ".
" -size 300x250 xc:black -bordercolor coral4 -border 1x1 ".
"-gravity center +swap -composite "; 
exec("convert $cmd output.png"); 
?>

The image is resized first and one border added then the background with the next border is created.