Page 1 of 1

Error distortImage with Mikko example

Posted: 2009-04-21T14:07:04-07:00
by badabou
Hello,

I have a problem with the function distortImage.

In fact, I just copied / pasted the example below on the mikko's blog and I have this error :

Fatal error: Uncaught exception 'ImagickException' with message 'invalid argument for option PerspectiveProjection : 'Needs 8 coefficient values'' in ...

Code: Select all

<?php
/* Create new object */
$im = new Imagick();
 
/* Create new checkerboard pattern */
$im->newPseudoImage(100, 100, "pattern:checkerboard");
 
/* Set the image format to png */
$im->setImageFormat('png');
 
/* Fill background area with transparent */
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
 
/* Activate matte */
$im->setImageMatte(true);
 
/* Control points for the distortion */
$controlPoints = array( 10, 10, 
                        10, 5,
 
                        10, $im->getImageHeight() - 20,
                        10, $im->getImageHeight() - 5,
 
                        $im->getImageWidth() - 10, 10,
                        $im->getImageWidth() - 10, 20,
 
                        $im->getImageWidth() - 10, $im->getImageHeight() - 10,
                        $im->getImageWidth() - 10, $im->getImageHeight() - 30); 
 
/* Perform the distortion */  
$im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);
 
/* Ouput the image */   
header("Content-Type: image/png");
echo $im;
?> 
Thank you for your help.

Re: Error distortImage with Mikko example

Posted: 2009-04-21T15:46:01-07:00
by spooky25
Probably not the kind of helpful response you prefer, but I get the same error when I run the code you posted. I'm running Image Magick 6.5.1 Q16 and ( if I remember correctly ) php_imagick_dyn-Q16.dll.

Re: Error distortImage with Mikko example

Posted: 2009-04-24T04:44:08-07:00
by badabou
Thank you for your reply.

Some details :

My configuration with which I have this problem is :

Windows XP
Imagick module version 2.2.1-dev (php_imagick_dyn-Q16.dll)
ImageMagick 6.5.1-6



When I use the same script on my linux server, it runs at half, there was no transparency (Image attached).

Re: Error distortImage with Mikko example

Posted: 2010-06-08T12:41:16-07:00
by esm723
Hey guys,

This problem has occurred before, so check out the thread there so that we can keep all of the info in one place.

viewtopic.php?f=18&t=9955&p=59631#p59631

Re: Error distortImage with Mikko example

Posted: 2010-06-25T21:25:23-07:00
by fmw42
If your perspective is so exaggerated that you are seeing the horizon, then you need to set the mattecolor. see http://www.imagemagick.org/Usage/distorts/#horizon