Imagick distort error.

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
sabater_wb

Imagick distort error.

Post 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.
ssweeney
Posts: 7
Joined: 2011-07-13T09:14:55-07:00
Authentication code: 8675308

Re: Imagick distort error.

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick distort error.

Post 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
ssweeney
Posts: 7
Joined: 2011-07-13T09:14:55-07:00
Authentication code: 8675308

Re: Imagick distort error.

Post 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!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Imagick distort error.

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply