Something like this would work:
<?php
//////////////////
// change these //
//////////////////
$file = './test.jpg';
$padding = 10;
$color = array (255, 255, 255);
/////////////////////////////
// these can stay the same //
/////////////////////////////
$size = @getimagesize ($file);
$blank = @imagecreatetruecolor ($size[0], $size[1] + $padding);
$original = @imagecreatefromjpeg ($file);
$col = @imagecolorallocate ($blank, $color[0], $color[1], $color[2]);
@imagefilledrectangle ($blank, 0, 0, $size[0], $size[1] + $padding, $col);
@imagecopyresized ($blank, $original, 0, 0, 0, 0, $size[0], $size[1], $size[0], $size[1]);
header ('Content-type: image/jpeg');
@imagejpeg ($blank);
@imagedestroy ($blank);
@imagedestroy ($original);
?>
Just customize the three variables and I think that should cover it... Although I only tested it with one image, so if you find some bugs please let me know. 🙂