用GD生成生成缩略图的两个选择和区别
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/****blog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>
PHP的GD扩展提供了两个函数来缩放图像:
来看一个例子,我们将这个图缩小四倍:

很明显可以看到两个函数生成的图像效果是不一样的,
ImageCopyResized(dest, src, dx, dy, sx, sy, dw, dh, sw, sh);
ImageCopyResampled(dest, src, dx, dy, sx, sy, dw, dh, sw, sh);
ImageCopyResized( )函数在所有GD版本中有效,但其缩放图像的算法比较粗糙,可能会导致图像边缘的锯齿。GD 2.x中新增了一个ImageCopyResampled( )函数,其像素插值算法得到的图像边缘比较平滑(但该函数的速度比ImageCopyResized()慢)。来看一个例子,我们将这个图缩小四倍:
<?php <br />
$src=ImageCreateFromJPEG('php.jpg');
$width=ImageSx($src);
$height=ImageSy($src);
$x=$width/2;$y=$height/2;
$dst=ImageCreateTrueColor($x,$y);
ImageCopyResized($dst,$src,0,0,0,0,$x,$y,$width,$height);
//ImageCopyResampled($dst,$src,0,0,0,0,$x,$y,$width,$height);
header('Content-Type:image/jpeg');
ImageJPEG($dst,'',100);
?>
原图:

使用
ImageCopyResized()函数生成的结果:

使用
ImageCopyResampled()函数生成的结果:
很明显可以看到两个函数生成的图像效果是不一样的,
ImageCopyResampled()函数生成的结果比较平滑,效果较好。
很有趣吧,呵呵..