Note: JPEG support is only available if PHP was compiled against GD-1.8 or later.

*参考 http://cn.php.net/imagecreatefromjpeg

前段时间一朋友问我最简单的做出缩略图,这里给了他答案,当然这样的方法非常不好

$sourceImage = 'images/baby.jpg';
$thumbWidth = 200;
$thumbHeight = 200;
$original = imagecreatefromjpeg($sourceImage);
$dims = getimagesize($sourceImage);
$thumb = imagecreatetruecolor($thumbWidth,$thumbHeight);

imagecopyresampled( $thumb, $original, 0, 0, 0, 0,
 $thumbWidth, $thumbHeight, $dims[0], $dims[1] );

header( “Content-type: image/jpeg” );
imagejpeg( $thumb );

转载请注明:韦旭红的点点滴滴 » 用PHP输出简单缩略图