裁剪图像后为什么会出现黑色区域​​?

时间:2014-01-15 07:50:57

标签: php gd crop

我的代码裁剪图片:

 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);
        }

结果: enter image description here

为什么在裁剪图像后会出现黑色区域​​?如何调整大小?

1 个答案:

答案 0 :(得分:0)

这段代码修好了:

 imagecopyresampled($new_image, $this->image, 0, 0, $x1, $y1, $this->getWidth(), $this->getHeight(), $newwidth, $newheight);