How to crop image in Image_Canvas PHP PEAR package

I can’t make it work, it just doesn’t do anything. I am using Image_Canvas PEAR package on shared hosting, but I can not crop the image.

My syntax is:

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

Any ideas?

+3
source share
1 answer

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

$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();
0
source

Source: https://habr.com/ru/post/1729835/


All Articles