$src_img=imagecreatefrompng('example.png');//源图片
$goal_img= imagecreatetruecolor($goal_width, $goal_height);//目标图片
imagecopyresampled($goal_img, $src_img, 0 , 0, 0, 0, $goal_width, $goal_height, $img_width, $img_height);//缩放
//输出
header('content-type:image/png');
imagepng( $goal_img);
imagedestroy($src_img);
imagedestroy($goal_img);