php imagecopyresized实例
描述
布尔imagecopyresized($ dst_image,$ src_image,$ dst_x,$ dst_y,$ src_x,$
src_y,$ dst_w,$ dst_h,$ src_w,$ src_h)
imagecopyresized()拷贝一个长方形的部分图像到另一个图像。 dst_image的目标图
像,src_image是源图像的标识符。
换句话说,imagecopyresized()将于src_w的宽度和高度src_h src_image的位置
(src_x,src_y),并将其放置在dst_w的宽度和高度dst_h dst_image矩形区域,它是
在位置的矩形区域(dst_x,dst_y)。
如果源和目标坐标,宽度和高度不同,适当的伸展或收缩的图像片段将进行。坐标是指
在左上角。该功能可用于复制的图像在同一地区(如dst_image是相同的src_image),
但如果区域重叠的结果将不可预测。
参数说明:
dst_im
目标图像链接的资源。
src_im
源图像链接的资源。
dst_x
X坐标的目的地。
dst_y
y坐标目的地。
src_x
X坐标的源点。
src_y
y坐标源点。
dst_w
目的地宽度。
dst_h
目标高度。
src_w
源宽度。
src_h
源高度。
来看看imagecopyresized函数实例
<?php // File and new size $filename = 'test.jpg'; $percent = 0.5; // Content type header('Content-type: image/jpeg'); // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb); ?>
本文地址:http://www.phprm.com/function/php-imagecopyresized.html
转载随意,但请附上文章地址:-)