您的位置:首页 > 编程语言 > PHP开发

PHP中imagecopyresampled()参数详解

2015-11-16 18:44 633 查看

imagecopyresampled()函数

bool imagecopyresampled ( resource dstimage,resourcedst_image , resource src_image , int dstx,intdst_x , int dst_y , int srcx,intsrc_x , int src_y , int dstw,intdst_w , int dst_h , int srcw,intsrc_w , int src_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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: