this is a just a real quick try at it, but you should be able to modify it to get it just how you want...
<?php
$file = "image.jpg";
$new = imagecreatetruecolor(250, 250);
imagefill($new, 0, 0, 0xFFFFFF);
$info = getimagesize($file);
$old = imagecreatefromjpeg($file);
if ($info[0] > 250 || $info[1] > 250) {
if ($info[0] > $info[1]) {
$ratio = $info[0] / 250;
} else {
$ratio = $info[1] / 250;
}
} else {
$ratio = 1;
}
imagecopyresized($new, $old, (250 - ($info[0] / $ratio)) / 2, (250 - ($info[1] / $ratio)) / 2, 0, 0, $info[0] / $ratio, $info[1] / $ratio, $info[0], $info[1]);
header("Content-Type: image/jpeg");
imagejpeg($new);
?>
not tested but it may be pretty close...