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

时间:2010-01-25 00:59:33

标签: php image pear crop

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

我的语法是:

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

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我对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();