如何在Image_Canvas PHP PEAR包中裁剪图像

时间:2021-01-24 07:14:25

I can't get it to work it just does nothing. I'm using Image_Canvas PEAR package on shared hosting it works but I can't crop image.

我无法让它工作它只是什么都不做。我在共享主机上使用Image_Canvas PEAR包它可以工作,但我无法裁剪图像。

My syntax is:

我的语法是:

$Canvas->setClipping(array('x0' => 10, 'y0' => 10, 'x1' => 200, 'y1' => 200));

Any ideas?

有任何想法吗?

1 个解决方案

#1


0  

I am not that familiar with Image_Canvas PEAR package, but I have tried it just now and found that setClipping will work if you add a second call to the same method without any parameters!

我对Image_Canvas PEAR包不太熟悉,但我刚刚尝试过,发现如果你在没有任何参数的情况下添加第二次调用同样的方法,setClipping将会起作用!

$Canvas =& Image_Canvas::factory((isset($_GET['canvas']) ? $_GET['canvas'] : 'png'), array('width' =>500, 'height' => 333, 'filename' => 'yourImage.jpg'));
$Canvas->setClipping(array('x0' => 10, 'y0' => 10, 'x1' => 200, 'y1' => 200));
$Canvas->image(array('x' => 0, 'y' => 0, 'filename' => './yourImage.jpg'));
$Canvas->setClipping();
$Canvas->show();

#1


0  

I am not that familiar with Image_Canvas PEAR package, but I have tried it just now and found that setClipping will work if you add a second call to the same method without any parameters!

我对Image_Canvas PEAR包不太熟悉,但我刚刚尝试过,发现如果你在没有任何参数的情况下添加第二次调用同样的方法,setClipping将会起作用!

$Canvas =& Image_Canvas::factory((isset($_GET['canvas']) ? $_GET['canvas'] : 'png'), array('width' =>500, 'height' => 333, 'filename' => 'yourImage.jpg'));
$Canvas->setClipping(array('x0' => 10, 'y0' => 10, 'x1' => 200, 'y1' => 200));
$Canvas->image(array('x' => 0, 'y' => 0, 'filename' => './yourImage.jpg'));
$Canvas->setClipping();
$Canvas->show();