所以我有这样的图像 - > http://i.imgur.com/bHdcBhd.png我需要裁掉红色区域。我尝试裁剪它,但功能是从顶部和底部裁剪整个图像。那么如何只裁剪图像的底部呢?最终结果是错误的(http://i.imgur.com/semxwyY.png)以下是代码:
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
function cutTheBottom($width, $height){
$height = $this->getHeight() - 55;
$width = $this->getWidth();
$x = ($this->getWidth() / 2) - ($width / 2);
$y = ($this->getHeight() / 2) - ($height / 2);
return $this->cut($x, $y, $width, $height);
}
function cut($x, $y, $width, $height)
{
$new_image = imagecreatetruecolor($width, $height);
imagecolortransparent($new_image, imagecolorallocate($new_image, 0, 0, 0));
imagealphablending($new_image, false);
imagesavealpha($new_image, true);
imagecopy($new_image, $this->image, 0, 0, $x, $y, $width, $height);
$this->image = $new_image;
}