PHP: 图片缩放、图片裁剪、图片水印

图片缩放:

#把一张大图缩略成不同的小图
imagecopyresampled( d s t i m g , dstimg, dstimg,srcimg,0,0,0,0,381,251,910,600);
imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool

imagecopyresampled() 将一幅图像中的一块正方形区域拷贝到另一个图像中,平滑地插入像素值,因此,尤其是,减小了图像的大小而仍然保持了极大的清晰度。

参数

dst_image

目标图象连接资源。

src_image

源图象连接资源。

dst_x

目标 X 坐标点。

dst_y

目标 Y 坐标点。

src_x

源的 X 坐标点。

src_y

源的 Y 坐标点。

dst_w

目标宽度。

dst_h

目标高度。

src_w

源图象的宽度。

src_h

源图象的高度。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE。


**


图片裁剪:

imagecopyresampled( d s t i m g , dstimg, dstimg,srcimg,0,0,200,200,381,251,300,200);
**


图片水印:

imagecopy( d s t i m g , dstimg, dstimg,srcimg,810,500,0,0,100,100);

说明
imagecopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) : bool

将 src_im 图像中坐标从 src_x,src_y 开始,宽度为 src_w,高度为 src_h 的一部分拷贝到 dst_im 图像中坐标为 dst_x 和 dst_y 的位置上。


左上角


打到右下角



**


**


你可能感兴趣的:(PHP)