<?php
//路径自己掌握,图片自己下载
$image = imagecreatefromjpeg("upload/cat.jpg");
//图片宽度和高度
$width = imagesx($image);
$height = imagesy($image);
//缩放尺寸
$th_width = $width * 0.5;
$th_hieght = $height * 0.5;
//创建画布
$th = imagecreatetruecolor($th_width,$th_hieght);
//复制图像至画布
imagecopyresampled($th,$image,0,0,0,0,$th_width,$th_hieght,$width,$height);
//生成图片
imagejpeg($th,"upload/cat_th.jpg",100);
//销毁句柄
imagedestroy($th);
?>
<span>shi yong php chuang jian suo lue tu</span>
<hr>
<table>
<tr>
<td>yuan tu:</td>
<td>suo lue tu:</td>
</tr>
<tr>
<td><img src="upload/cat.jpg"></td>
<td valign="top"><img src="upload/cat_th.jpg"></td>
</tr>
</table>