Вот, пожалуйста:
function MagicStretch(&$image,$newwidth)
{
$width=imagesx($image);
$height=imagesy($image);
$halfwidth=round(($width-2)/2);
$new=imagecreatetruecolor($newwidth,$height);
imagecopyresized($new,$image,$halfwidth,0,$halfwidth-1,0,$newwidth-($halfwidth*2),$height,2,$height);
imagecopy($new,$image,0,0,0,0,$halfwidth,$height);
imagecopy($new,$image,$newwidth-$halfwidth,0,$width-$halfwidth,0,$halfwidth,$height);
imagedestroy($image);
return $new;
}
$image = imagecreatefrompng('whatever.png');
$image = MagicStretch($image,320);
imagepng($image,'whatever_new.png');