2010-01-25 45 views
3

我無法讓它工作,它只是無所作爲。我在共享主機上使用Image_Canvas PEAR軟件包,但無法裁剪圖像。如何在Image_Canvas中裁剪圖像PHP PEAR包

我的語法是:

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

任何想法?

回答

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