PHP中imagecopyresampled()参数详解

来源:互联网 发布:unity3d按轨迹运动 编辑:程序博客网 时间:2024/05/16 17:17

imagecopyresampled()函数

bool imagecopyresampled ( resource dstimage,resourcesrc_image , int dstx,intdst_y , int srcx,intsrc_y , int dstw,intdst_h , int srcw,intsrc_h )

$dst_image:新建的图片

$src_image:需要载入的图片

$dst_x:设定需要载入的图片在新图中的x坐标

$dst_y:设定需要载入的图片在新图中的y坐标

$src_x:设定载入图片要载入的区域x坐标

$src_y:设定载入图片要载入的区域y坐标

$dst_w:设定载入的原图的宽度(在此设置缩放)

$dst_h:设定载入的原图的高度(在此设置缩放)

$src_w:原图要载入的宽度

$src_h:原图要载入的高度

For example:

    $filename="20151126.jpg";    $percent=0.2;    header("Content-type:image/jpeg");    list($width,$height)=getimagesize($filename);    $newWidth=$width*$percent;    $newHeight=$height*$percent;    $thumb=imagecreatetruecolor($newWidth,$newHeight);    $source=imagecreatefromjpeg($filename);    imagecopyresampled($thumb,$source,0,0,0,0,$newWidth,$newHeight,$width,$height);    imagejpeg($thumb);
0 1