I’m trying to distort an image in perspective via imagick php extension and I’ve got the following piece of code for doing this:
$controlPoints = array(
0,0, 0,0,
0,$height, 0,$height,
$width,0, $width,$perspective_wrap,
$width,$height, $width,$hps
);
$im1->setImageMatte(true);
//Distort the image -- In perspective with the matrix given above
$im1->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);
The image is distorting in perspective on a linux server but when I move the script on windows hosting it seems that the following error occurs:
Fatal error: Uncaught exception ‘ImagickException’ with message ‘Can’t read argument array’
Where the line is $im1->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);
Is there any way to make it work on both platforms?
It seems that on my linux server I had the following Imagick Version:
ImageMagick version: ImageMagick 6.7.6-8 2012-05-02 Q16
and on the windows server:
ImageMagick version ImageMagick 6.4.1 05/16/08 Q16
So, on the windows server the $controlPoints array must have all the elements as INT values. On the linux server and that image magick version there was no problem if some values were string so the solution to the problem was to convert the $controlPoints array values into int values.
Hope it helps if someone get’s over this problem like I did.