<?php
header("Content-type: image/jpeg");
//原图文件
$file = "images/flower_1.jpg";
// 缩略图比例
$percent = 0.5;
// 缩略图尺寸
list($width, $height) = getimagesize($file);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// 加载图像
$src_im = @imagecreatefromjpeg($file);
$dst_im = imagecreatetruecolor($newwidth, $newheight);
// 调整大小
imagecopyresized($dst_im, $src_im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//输出缩小后的图像
imagejpeg($dst_im);
imagedestroy($dst_im);
imagedestroy($src_im);
?>
来自:http://www.5idev.com/p-php_imagecopy_imagecopyresized.shtml#imagecopy
bool imagecopyresized ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )
将一幅图像中的一块正方形区域拷贝到另一个图像中。dst_image 和 src_image 分别是目标图像和源图像的标识符。如果源和目标的宽度和高度不同,则会进行相应的图像收缩和拉伸。坐标指的是左上角。本函数可用来在同一幅图内部拷贝(如果 dst_image 和 src_image 相同的话)区域,但如果区域交迭的话则结果不可预知。
bool imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h )
将 src_im 图像中坐标从 src_x,src_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_x 和 dst_y 的位置上。