我的代码裁剪图片:
function cropimage($x1,$y1,$newwidth, $newheight) {
$new_image = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($new_image, $this->image, $x1, $y1, 0, 0, $newwidth, $newheight, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
$this->image->save($file);
}
结果:
为什么在裁剪图像后会出现黑色区域?如何调整大小?
答案 0 :(得分:0)
这段代码修好了:
imagecopyresampled($new_image, $this->image, 0, 0, $x1, $y1, $this->getWidth(), $this->getHeight(), $newwidth, $newheight);