I use a simple php code (taken from php.net example) to resize an image
list($width, $height) = getimagesize($filename);
$new_height = $height / $width * 400;
$image_p = imagecreatetruecolor(400, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 400, $new_height, $width, $height);
imagejpeg($image_p, "new.jpg");
Here, we create a blank image and merge it with the resized image. I wonder if it is the simplest way to resize and save an image. Is it really necessary to create a blank background image?