ImageCopyResampled
PHP中缩放图像.
有两种改变图像大小的方法.
(1):ImageCopyResized() 函数在所有GD版本中有效,但其缩放图像的算法比较粗糙.
(2):ImageCopyResamples(),其像素插值算法得到的图像边缘比较平滑.(但该函数的速度比 ImageCopyResized() 慢).
两个函数的参数是一样的.如下:
ImageCopyResampled(dest,src,dy,dx,sx,sy,dw,dh,sw,sh);
ImageCopyResized(dest,src,dy,dx,sx,sy,dw,dh,sw,sh);
<?PHP //例子
$src = ImageCreateFromJPEG('php.jpg');
$width = ImageSx($src);
$height = ImageSy($src);
$x = $widht/2;
$y = $height/2;
$dst = ImageCreateTrueColor($x,$y);
ImageCopyResampled($dst,$src,0,0,0,0,$x,$y,$widht,$height);
header('Content-Type : image/png');
ImagePNG($det);
?>