您可以
imagecopy用来裁剪图像的必需部分。该命令如下所示:
imagecopy ( resource $dst_im - the image object , resource $src_im - destination image , int $dst_x - x coordinate in the destination image (use 0) , int $dst_y - y coordinate in the destination image (use 0) , int $src_x - x coordinate in the source image you want to crop , int $src_y - y coordinate in the source image you want to crop , int $src_w - crop width , int $src_h - crop height )
来自PHP.net的代码-
从源图像中裁剪出一个80x40像素的图像
<?php// Create image instances$src = imagecreatefromgif('php.gif');$dest = imagecreatetruecolor(80, 40);// Copyimagecopy($dest, $src, 0, 0, 20, 13, 80, 40);// Output and free from memoryheader('Content-Type: image/gif');imagegif($dest);imagedestroy($dest);imagedestroy($src);?>


