Page 1 of 1

Imagick distort error.

Posted: 2009-07-25T19:52:23-07:00
by sabater_wb
I'm trying to run a test script but I get error.

My script is like this:

$im = new Imagick($file);


$controlPoints = array( 0, 0,
$ax,$ay,

10,$minheight,
$bx,$by,

$minwidth, 0,
$cx,$cy,

$minwidth,$minheight,
$dx,$nem);

$im->distortImage(Imagick::DISTORTION_PERSPECTIVEPROJECTION, $controlPoints, true);

$im->writeImage("result.jpg");
$im->destroy();


Every time I run it I get this error message:


Fatal error: Uncaught exception 'ImagickException' with message 'Can't read argument array' in D:\path-to-script\script.php:196 Stack trace: #0 D:\path-to-script\script.php(196): Imagick->distortimage(6, Array, true) #1 D:\path-to-script\script.php(104): include('D:\path-to-script...') #2 D:\path-to-script\script.php(191): include('D:\path-to-script...') #3 {main} thrown in D:\path-to-script\script.php on line 196

What is this error. What can I do to solve it?

If I put the strings values instead the string name inside of the array it works perfect.

Re: Imagick distort error.

Posted: 2011-07-18T12:33:44-07:00
by ssweeney
Good Afternoon,

I know this is really old but I just ran into this issue as well. Anyone have any thoughts? It doesn't like the fact I'm using variables, however using literal values works just fine.

Thanks!

Re: Imagick distort error.

Posted: 2011-07-18T12:40:31-07:00
by fmw42
You are using the wrong function. You have DISTORTION_PERSPECTIVEPROJECTION, but are using control points and not projection coefficients. So change your DISTORTION_PERSPECTIVEPROJECTION to DISTORTION_PERSPECTIVE

see

http://us3.php.net/manual/en/imagick.co ... distortion

Re: Imagick distort error.

Posted: 2011-07-18T12:46:23-07:00
by ssweeney
Cool. I should have been a little more specific my issue was using distortImage with DISTORTION_AFFINE so maybe mine wasn't completely related.

Shortly after posting I was able to get this to work. The issue in my case was I had to specifically typecast my variables. I was doing an explode on a comma seperated list of ints. Typecasting each variable to int did the trick.

Thanks!

Re: Imagick distort error.

Posted: 2011-07-18T22:15:01-07:00
by anthony
Also you create a image data variable, but don't read or create any image into that variable.
Basically you do not have any image in memory whcih is why there is a fatal error.